/** * (non-PHPdoc). * * @see \Sonata\AdminBundle\Admin\Admin::prePersist() */ public function prePersist($object) { /* @var $object MetaTagContent */ $path = $this->getForm()->get('path')->getData(); if (strpos('/', $path) !== false) { $path = '/' . $path; } try { $key = $this->keyGenerator->generateMetaTagKeyFromRelativePath($path, $this->getRouter(), $this->translator->getLocale()); $object->setKeyword($key); } catch (\Exception $e) { } }
/** * @param $alias * @param $path * @param array $pathParameters * @param null $locale * @param null $title * @param null $keywords * @param null $description * * @return ContentInterface * * @internal param array $metatags */ public function createNewAlias($alias, $path, array $pathParameters = array(), $locale = null, $title = null, $keywords = null, $description = null) { $rc = new \ReflectionClass($this->entityClass); $object = $rc->newInstance(); if (!$object instanceof ContentInterface) { return; } $object->setAlias($alias); $pathParameters[UrlGenerator::GENERATE_NORMAL_ROUTE] = true; $path = $this->router->generate($path, $pathParameters); $path = str_replace('/app_dev.php', '', $path); $key = $this->generator->generateMetaTagKeyFromRelativePath($path, $this->router, $locale); $object->setKeyword($key); $object->setTitle($title); $object->setKeywords($keywords); $object->setDescription($description); return $object; }