Example #1
0
 /**
  * Returns the global extension collection instance.
  *
  * @return ExtensionCollection The extension collection.
  */
 public static function getInstance()
 {
     static $instance = null;
     if (null === $instance) {
         $instance = new self();
         foreach (self::getDefaultExtensions() as $extension) {
             $instance->attach($extension);
         }
     }
     return $instance;
 }
Example #2
0
 /**
  * Install a new Peridot Phony plugin to the supplied emitter.
  *
  * @return self The newly created plugin.
  */
 public static function install(EventEmitterInterface $emitter)
 {
     $instance = new self();
     $instance->attach($emitter);
     return $instance;
 }
 /**
  * Fetch one or more resolvers that match the given type.
  *
  * @param string $type
  * @return ResolverInterface Return the matched instance, or an aggregate
  *     containing all matched instances.
  * @throws Exception\ResolverTypeNotFoundException if no resolvers of the type are found.
  */
 public function fetchByType($type)
 {
     if (!$this->hasType($type)) {
         throw new Exception\ResolverTypeNotFoundException();
     }
     $resolvers = new self();
     foreach ($this as $resolver) {
         if ($resolver instanceof $type) {
             $resolvers->attach($resolver);
         }
     }
     if (1 === count($resolvers)) {
         return $resolvers->queue->extract();
     }
     return $resolvers;
 }
Example #4
0
 /**
  * @param callable $callback
  *
  * @return PointSet
  */
 public function map($callback)
 {
     $result = new self();
     foreach ($this as $point) {
         $value = $this[$point];
         if (call_user_func($callback, $point, $value)) {
             $result->attach($point, $value);
         }
     }
     return $result;
 }
Example #5
0
 static function send($to, $subject, $msg, $attach = '', $attachFilename = '')
 {
     $e = new self();
     $e->setFrom(ini::get('email-address'), ini::get('email-name'));
     $e->setTo($to);
     $e->setSubject($subject);
     $e->setBody($msg);
     if (strlen($attach)) {
         $e->attach($attach, strlen($attachFilename) ? $attachFilename : 'attachment-1');
     }
     return $e->mail();
 }
Example #6
0
 public static function merge()
 {
     $buffer = new self();
     if (func_num_args() > 0) {
         $args = func_get_args();
         foreach ($args as $objectStorage) {
             foreach ($objectStorage as $object) {
                 if (is_object($object)) {
                     $buffer->attach($object);
                 }
             }
         }
     } else {
         return false;
     }
     return $buffer;
 }