Esempio n. 1
0
 public function setUp()
 {
     $this->wordpress = wordpress();
     $this->wordpress->reset();
     $this->model = Model::factory("TestStateless");
     $this->customPostType = CustomPostType::factory("TestCustomPostType");
 }
 public function rewriteStrataPost($postTypekey, $config)
 {
     try {
         $cpt = CustomPostType::factory(substr($postTypekey, 4));
         $localizedSlugs = array_merge(array($cpt->hasConfig("rewrite.slug") ? $cpt->getConfig("rewrite.slug") : $postTypekey), $cpt->extractConfig("i18n.{s}.rewrite.slug"));
         $this->addCustomPostTypeRewrites(implode("|", $localizedSlugs), $postTypekey);
     } catch (Exception $e) {
         Strata::app()->log("Tried to translate {$slug}, but could not find the associated model.", "<magenta>Polyglot:UrlRewriter</magenta>");
     }
 }
 /**
  * Loads the entities.
  */
 public function load()
 {
     // Even though we can't confirm the entity has
     // been loaded, we should still inform the user.
     $this->logAutoloadedEntities();
     $configuration = $this->getConfiguration();
     if (count($configuration)) {
         foreach ($configuration as $cpt => $config) {
             $obj = CustomPostType::factory($cpt);
             $this->addWordpressRegisteringAction($obj);
             if ($this->shouldAddAdminMenus($obj)) {
                 $this->addWordpressMenusRegisteringAction($obj);
             }
             if ($this->shouldAddRoutes($obj)) {
                 $this->addResourceRoute($obj);
             }
         }
         // The second we register an internal CPT it becomes worth
         // looking for additional model routes.
         add_action('wp_loaded', array(new ModelRewriteRegistrar(), "onModelsActivated"), 5);
     }
 }
Esempio n. 4
0
 /**
  * Returns the accompanying Model of this entity.
  * @return Strata\Model
  */
 public function getModel()
 {
     $name = $this->getShortName();
     $name = str_replace("Entity", "", $name);
     return CustomPostType::factory($name);
 }