Example #1
0
 /**
  * Creates an instance with data
  *
  * @param  array $data
  * @return self
  */
 public static function create(array $data = array())
 {
     $defaults = array('id' => null, 'folder_id' => null, 'profile' => null, 'name' => null, 'date_created' => new DateTime(), 'status' => null, 'resource' => null, 'uuid' => null, 'data' => new IdentifiableDataContainer(array()));
     $data = array_merge($defaults, $data);
     $obj = new self();
     $obj->setId($data['id']);
     $obj->setFolderId($data['folder_id']);
     $obj->setProfile($data['profile']);
     $obj->setName($data['name']);
     $obj->setDateCreated($data['date_created']);
     $obj->setStatus($data['status']);
     $obj->setResource($data['resource']);
     $obj->setUuid($data['uuid']);
     $obj->setData($data['data']);
     return $obj;
 }
Example #2
0
 /**
  * Метод выполняет создание пары стримов. Часто применяется для межпроцессного взаимодействия.
  *
  * @static
  * @param Ext_Io_Net_Socket_ProtocolFamily    $domain
  * @param Ext_Io_Net_Socket_CommunicationType $type
  * @param Ext_Io_Net_Stream_Protocol          $protocol
  * @return array
  */
 public static function createPair(Ext_Io_Net_Socket_ProtocolFamily $domain, Ext_Io_Net_Socket_CommunicationType $type, Ext_Io_Net_Stream_Protocol $protocol)
 {
     $resources = stream_socket_pair($domain->getValue(), $type->getValue(), $protocol->getValue());
     foreach ($resources as &$resource) {
         $tmpResource = new self();
         $tmpResource->setResource($resource);
         $resource = $tmpResource;
     }
     return $resources;
 }
Example #3
0
 /**
  * Creates new Image object from image resource
  *
  * @param resource $resource Image resource
  * @throws ImageException
  * @return self
  */
 public static function fromResource($resource)
 {
     $newImage = new self();
     try {
         $newImage->setResource($resource);
     } catch (\Exception $e) {
         throw new ImageException($e->getMessage(), ImageException::UnsupportedFormatException, $e);
     }
     return $newImage;
 }
Example #4
0
 /**
  * Creates an instance of image from resource
  */
 public static function fromResource($resource)
 {
     $image = new self();
     $image->setResource($resource);
     return $image;
 }