コード例 #1
0
 /**
  * Enregistrement d'une action
  * @param  object $object    [description]
  * @param  string $action      [description]
  * @param  mixed  $from_user   [description]
  * @param  mixed  $to_user     [description]
  * @param  mixed  $child_object Peut être un objet enfant ou juste le type de cet objet
  * @return [type]              [description]
  */
 public function record($object, $action, $from_user = null, $child_object = null, $to_user = null)
 {
     $instantiator = new \Doctrine\Instantiator\Instantiator();
     $activity = $instantiator->instantiate($this->activity_class);
     $activity->setDate(new \DateTime());
     $activity->setObject($object);
     $activity->setObjectType($this->getClassBasename($object));
     $activity->setAction($action);
     if (!is_null($from_user) && $from_user instanceof AdvancedUserInterface) {
         $activity->setFromUser($from_user);
     }
     if (!is_null($to_user) && $to_user instanceof AdvancedUserInterface) {
         $activity->setToUser($to_user);
     }
     if (!is_null($child_object)) {
         if (is_object($child_object)) {
             $activity->setChildObject($child_object);
             $activity->setChildObjectType($this->getClassBasename($child_object));
         } else {
             $activity->setChildObjectType($child_object);
         }
     }
     $this->dm->persist($activity);
     $this->dm->flush();
 }
コード例 #2
0
 /**
  *
  * @param string $className        	
  *
  * @return object
  */
 public function instantiate($className)
 {
     if (!class_exists($className)) {
         throw new ClassNotFoundException("Class {$className} does not exist.", $className);
     }
     $instantiator = new \Doctrine\Instantiator\Instantiator();
     return $instantiator->instantiate($className);
 }
コード例 #3
0
 /**
  * Retourne un message construit à partir des body et subject
  * @param  string $body          
  * @param  string $subject       
  * @param  array  $template_vars [description]
  * @return SwiftMessage                
  */
 public function getMessageFromData($body, $subject, $template_vars = array())
 {
     $instantiator = new \Doctrine\Instantiator\Instantiator();
     $template = $instantiator->instantiate($this->template_class);
     $template->setTwigEngine($this->twig);
     $template->setBody($body);
     $template->setSubject($subject);
     // Construct and return message
     return \Swift_Message::newInstance()->setSubject($template->getFinalSubject($template_vars))->setBody($template->getFinalBody($template_vars), 'text/html');
 }
コード例 #4
0
 /**
  * @param string $class
  * @return \Exception
  */
 private function createResultException($class)
 {
     $instantiator = new \Doctrine\Instantiator\Instantiator();
     $exception = $instantiator->instantiate($class);
     return $exception;
 }
コード例 #5
0
ファイル: EntityManager.php プロジェクト: lynx/lynx
 /**
  * @param string $className
  * @return object
  */
 public function getObject($className)
 {
     $instantiator = new \Doctrine\Instantiator\Instantiator();
     return $instantiator->instantiate($className);
 }