Skip to content

Commit

Permalink
added: support for EntityTools migrate feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Nov 3, 2016
1 parent ebb8220 commit 7b93767
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions classes/ColdTrick/StaticPages/MigrateStatic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace ColdTrick\StaticPages;

use ColdTrick\EntityTools\Migrate;

class MigrateStatic extends Migrate {

/**
* Add static to the supported types for EntityTools
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param array $return_value current return value
* @param mixed $params supplied params
*
* @return array
*/
public static function supportedSubtypes($hook, $type, $return_value, $params) {

$return_value[\StaticPage::SUBTYPE] = self::class;

return $return_value;
}

/**
* {@inheritDoc}
* @see \ColdTrick\EntityTools\Migrate::setSupportedOptions()
*/
protected function setSupportedOptions() {
$this->supported_options = [
'backdate' => true,
'change_owner' => false,
'change_container' => true,
];
}

/**
* {@inheritDoc}
* @see \ColdTrick\EntityTools\Migrate::changeContainer()
*/
public function changeContainer($new_container_guid) {

// do all the default stuff
parent::changeContainer($new_container_guid);

// also move owner
$this->object->owner_guid = $new_container_guid;
}
}
1 change: 1 addition & 0 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function static_init() {
elgg_register_plugin_hook_handler('cron', 'daily', '\ColdTrick\StaticPages\Cron::daily');

elgg_register_plugin_hook_handler('likes:is_likable', 'object:' . \StaticPage::SUBTYPE, '\Elgg\Values::getTrue');
elgg_register_plugin_hook_handler('supported_types', 'entity_tools', '\ColdTrick\StaticPages\MigrateStatic::supportedSubtypes');

// actions
elgg_register_action('static/edit', dirname(__FILE__) . '/actions/edit.php');
Expand Down

0 comments on commit 7b93767

Please sign in to comment.