Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function add(ObjectInterface $object)
 {
     if (!$object->getParentId() && $this->container) {
         $object->setParentId($this->container->getId());
     }
     $this->objects[] = $object;
 }
Exemplo n.º 2
0
 /**
  * Publish an event by calling all listeners that have registered to receive it.
  *
  * @param  string|EventInterface  $event     The event name or a EventInterface object
  * @param  array|Traversable       $attributes An associative array or a Traversable object
  * @param  ObjectInterface        $target    The event target
  * @return null|EventInterface Returns the event object. If the chain is not enabled will return NULL.
  */
 public function publishEvent($event, $attributes = array(), $target = null)
 {
     if ($this->isEnabled()) {
         //Make sure we have an event object
         if (!$event instanceof EventInterface) {
             $event = new Event($event, $attributes, $target);
         }
         //Notify the listeners
         $listeners = $this->getListeners($event->getName());
         foreach ($listeners as $listener) {
             $start = microtime(true);
             call_user_func($listener, $event, $this);
             $this->__profiles[] = array('message' => $event->getName(), 'period' => microtime(true) - $start, 'time' => microtime(true), 'memory' => $this->getMemoryUsage(), 'target' => $target instanceof ObjectInterface ? $target->getIdentifier() : $target, 'listener' => $listener);
             if (!$event->canPropagate()) {
                 break;
             }
         }
         return $event;
     } else {
         $this->getDelegate()->publishEvent($event, $attributes, $target);
     }
     return null;
 }
Exemplo n.º 3
0
 /**
  * Convert the RPSL objects into its JSON representation.
  * 
  * @param ObjectInterface $object RPSL object.
  * @return string
  */
 public function createJSON(ObjectInterface $object)
 {
     $source = $object->getAttribute('source');
     if (!$source->isDefined()) {
         $source->addValue($this->getSource(\CASE_UPPER));
     }
     // otherwise the intended exception won’t make it through
     return json_encode($object->toArray());
 }
Exemplo n.º 4
0
 public function __toString()
 {
     return $this->file->getContent();
 }
Exemplo n.º 5
0
 /**
  * Check if the user is equal
  *
  * @param  UserInterface $user
  * @return Boolean
  */
 public function equals(ObjectInterface $user)
 {
     if ($user instanceof UserInterface) {
         if ($user->getEmail() == $this->getEmail()) {
             if ($user->getPassword() == $this->getPassword()) {
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * @inheritDoc
  */
 public function isEqual(ObjectInterface $obj)
 {
     return $obj->getId() == $this->getId() && $this->type() == $obj->type();
 }