/**
  * Transforms an id to entity
  *
  * @param integer $id
  *
  * @return object
  */
 public function reverseTransform($id)
 {
     if (null == $id) {
         return null;
     }
     $entity = $this->contentManager->getRepository()->find($id);
     return $entity;
 }
 /**
  * {@inheritDoc}
  */
 public function load($id = 0)
 {
     $this->content = $this->contentManager->getRepository()->find($id);
     if (!$this->content) {
         throw $this->createNotFoundException('No content found for id ' . $id);
     }
     $this->setTemplate($this->content->getTemplate());
     return $this;
 }
Example #3
0
 /**
  * Create a new contentType instance.
  *
  * @return ContentType
  */
 public function create()
 {
     $class = $this->getClass();
     $contentType = new $class();
     $schema = $this->schemaManager->create();
     $schema->setObjectClass($this->contentManager->getClass());
     $contentType->setSchema($schema);
     return $contentType;
 }
Example #4
0
 public function save(ContentInterface $content)
 {
     if (!$content->getId()) {
         $content->setAuthor($this->tokenStorage->getToken()->getUser());
     }
     return parent::save($content);
 }
Example #5
0
 /**
  * Processes a POST request to subscribe.
  *
  * @param Block $block
  *
  * @return Response
  */
 public function subscribeAction(Block $block)
 {
     $response = $this->execute($block);
     $properties = $block->getProperties();
     if ($this->subscribed && isset($properties['responseType']) && $properties['responseType'] == 'redirect') {
         $content = $this->contentManager->getRepository()->find($properties['responseContent']);
         $response = new RedirectResponse($this->router->generate('_content', ['slug' => $content->getSlug()]));
     }
     return $response;
 }
Example #6
0
 public function getBreadcrumbs(ContentInterface $content)
 {
     $return = [];
     $breadcrumbs = $content->getBreadcrumbs();
     if (sizeof($breadcrumbs) == 1 && key($breadcrumbs) == 'index') {
         return $return;
     }
     $index = 0;
     foreach ($breadcrumbs as $slug => $title) {
         if (substr($slug, -6) == '/index') {
             continue;
         }
         $indexSlug = sizeof($breadcrumbs) - 1 == $index ? $slug : $slug . '/index';
         if ($content = $this->contentManager->getRepository()->findOneBy(['slug' => $indexSlug])) {
             $return[$slug . '/'] = $content->getTitle();
         }
         $index++;
     }
     return $return;
 }
Example #7
0
 /**
  * {@inheritDoc}
  */
 public function postPublish()
 {
     $this->subject->setUpdatedAt(new \DateTime());
     $this->contentManager->save($this->subject);
     return $this;
 }
 public function testGetClass()
 {
     $manager = new ContentManager($this->em, $this->formFactory, $this->eavManager, $this->contentClass, $this->templateClass, $this->tokenStorage);
     $this->assertEquals('Opifer\\ContentBundle\\Tests\\TestData\\Content', $manager->getClass());
 }
 /**
  * {@inheritDoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['multiple' => true, 'property' => 'title', 'class' => $this->contentManager->getClass()]);
 }