Exemplo 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>");
     }
 }
Exemplo n.º 3
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);
 }
 protected function localizeStaticSlugs($localizedPost, $routedUrl, $originalUrl)
 {
     // Localize back the parameters in the default language
     if (!$this->currentLocale->isDefault()) {
         if (preg_match('/' . preg_quote($localizedPost->post_name) . '\\/(.+?)$/', $routedUrl, $matches)) {
             $cpt = CustomPostType::factoryFromKey($localizedPost->post_type);
             $key = "i18n." . $this->currentLocale->getCode() . ".rewrite.slug";
             if ($cpt->hasConfig($key)) {
                 $additionalParameters = Utility::replaceFirstOccurence($cpt->getConfig($key), $cpt->getConfig("rewrite.slug"), $additionalParameters);
             }
         }
     }
     return trailingslashit($originalUrl);
 }
 /**
  * Queues the $customPostType's admin menus for registration.
  * @param CustomPostType $customPostType
  */
 private function addWordpressMenusRegisteringAction(CustomPostType $customPostType)
 {
     $customPostType->registerAdminMenus();
 }