Exemple #1
0
 /**
  * {@inheritDoc}
  */
 public function filter($content, array $options = array())
 {
     if ($this->blockProperty->getMetadata()->offsetExists('link')) {
         $element = $this->blockProperty->getMetadata()->get('link')->getReferencedElement();
         if ($element !== null) {
             /* @var $element LinkReferencedElement */
             if (!$element instanceof LinkReferencedElement) {
                 // @TODO: any exception should be thrown probably
                 return null;
             }
             // @TODO: the same code is inside HtmlFilter, should combine somehow.
             $title = ReferencedElementUtils::getLinkReferencedElementTitle($element, $this->container->getDoctrine()->getManager(), $this->container->getLocaleManager()->getCurrentLocale());
             // @TODO: what if we failed to obtain the URL?
             $url = ReferencedElementUtils::getLinkReferencedElementUrl($element, $this->container->getDoctrine()->getManager(), $this->container->getLocaleManager()->getCurrentLocale());
             $tag = new HtmlTag('a', $title ? $title : $url);
             $tag->setAttribute('title', $title)->setAttribute('href', $url)->setAttribute('class', $element->getClassName());
             $target = $element->getTarget();
             if (!empty($target)) {
                 $tag->setAttribute('target', $target);
             }
             switch ($element->getResource()) {
                 case LinkReferencedElement::RESOURCE_FILE:
                     $tag->setAttribute('target', '_blank');
                     break;
             }
             return $tag;
         }
     }
     return null;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $registry = $this->container->getDoctrine();
     $em = $registry->getManager($input->getOption('em'));
     $con = $registry->getConnection($input->getOption('con'));
     $helperSet = $this->getApplication()->getHelperSet();
     $helperSet->set(new EntityManagerHelper($em), 'em');
     parent::execute($input, $output);
 }
 public function write($session_id, $session_data)
 {
     $entity = $this->container->getDoctrine()->getRepository('Framework:SessionData')->findOneBy(array('sessionId' => $session_id));
     if ($entity) {
         $entity->setData($session_data);
         $entity->setTimestamp(time());
         $this->container->getDoctrine()->getManager()->flush();
     } else {
         $entity = new SessionData();
         $entity->setSessionId($session_id);
         $entity->setData($session_data);
         $this->container->getDoctrine()->getManager()->persist($entity);
         $this->container->getDoctrine()->getManager()->flush();
     }
 }
Exemple #4
0
 /**
  * @param AbstractPage $source
  * @return AbstractPage
  */
 public function copyAbstractPage(AbstractPage $source)
 {
     $deepCopy = new DeepCopy();
     $entityManager = $this->container->getDoctrine()->getManagerForClass(get_class($source));
     $deepCopy->addFilter(new KeepFilter(), new PropertyMatcher(AbstractPage::CN(), 'nestedSetNode'));
     $this->addDeepCopyCommonFilters($deepCopy, $entityManager);
     $copiedPage = $deepCopy->copy($source);
     $entityManager->persist($copiedPage);
     return $copiedPage;
 }
Exemple #5
0
 /**
  * Parse supra.link, return beginning part of referenced link element.
  * 
  * @param LinkReferencedElement $link
  * @return HtmlTagStart
  */
 protected function parseSupraLinkStart(LinkReferencedElement $link)
 {
     $tag = new HtmlTagStart('a');
     $title = ReferencedElementUtils::getLinkReferencedElementTitle($link, $this->container->getDoctrine()->getManager(), $this->container->getLocaleManager()->getCurrentLocale());
     // @TODO: what if we failed to obtain the URL?
     $url = ReferencedElementUtils::getLinkReferencedElementUrl($link, $this->container->getDoctrine()->getManager(), $this->container->getLocaleManager()->getCurrentLocale());
     $tag->setAttribute('title', $title)->setAttribute('href', $url)->setAttribute('class', $link->getClassName());
     $target = $link->getTarget();
     if (!empty($target)) {
         $tag->setAttribute('target', $target);
     }
     switch ($link->getResource()) {
         case LinkReferencedElement::RESOURCE_FILE:
             $tag->setAttribute('target', '_blank');
             break;
     }
     return $tag;
 }
 /**
  * @return \Doctrine\Common\Persistence\ObjectManager
  */
 protected function getEntityManager()
 {
     return $this->container->getDoctrine()->getManager();
 }
Exemple #7
0
 /**
  * @return EntityManager
  */
 public function getDoctrineEntityManager()
 {
     return $this->container->getDoctrine()->getManager();
 }
 public function finish(ContainerInterface $container)
 {
     $container->setParameter('cms_authentication.provider_key', 'cms_authentication');
     $container['cms_authentication.users.voters'] = function (ContainerInterface $container) {
         $voters = array();
         foreach ($container->getParameter('cms_authentication.users.voters') as $id) {
             $voters[] = $container[$id];
         }
         return $voters;
     };
     $container['cms_authentication.users.access_decision_manager'] = function (ContainerInterface $container) {
         return new AccessDecisionManager($container['cms_authentication.users.voters']);
     };
     $container['cms_authentication.encoder_factory'] = function (ContainerInterface $container) {
         $encoders = array();
         foreach ($container->getParameter('cms_authentication.users.password_encoders') as $user => $encoderClass) {
             $encoders[$user] = new $encoderClass();
         }
         return new EncoderFactory($encoders);
     };
     $container['cms_authentication.users.authentication_manager'] = function (ContainerInterface $container) {
         $providers = array();
         foreach ($container->getParameter('cms_authentication.users.user_providers') as $type => $providersDefinition) {
             if ($type != 'doctrine') {
                 throw new \Exception('Only "doctrine" user providers are allowed now');
             }
             foreach ($providersDefinition as $name => $providerDefinition) {
                 $provider = $container->getDoctrine()->getManager($providerDefinition['em'])->getRepository($providerDefinition['entity']);
                 $provider->setDefaultDomain($container->getParameter('cms_authentication.users.default_domain'));
                 $providers[] = $provider;
             }
             $chainProvider = new ChainUserProvider($providers);
             $realProviders = array(new AnonymousAuthenticationProvider(uniqid()), new DaoAuthenticationProvider($chainProvider, new UserChecker(), $container->getParameter('cms_authentication.provider_key'), $container['cms_authentication.encoder_factory']));
             return new AuthenticationProviderManager($realProviders);
         }
         return new AuthenticationProviderManager($providers);
     };
     $container['security.context'] = function (ContainerInterface $container) {
         return new SecurityContext($container['cms_authentication.users.authentication_manager'], $container['cms_authentication.users.access_decision_manager']);
     };
 }