public static function loadJson($filename) { $config = json_decode(file_get_contents($filename), true); $validator = new self(); $validator->configure($config['rules'], $config['messages'], $config['labels']); return $validator; }
/** * Creates a basic auth client with the supplied configuration options * * @param array $config * @return Client|IntercomBasicAuthClient */ public static function factory($config = []) { $client = new self(); $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required); $client->configure($config); $client->setBasicAuth($config->get('app_id'), $config->get('api_key')); return $client; }
/** * Creates a basic auth client with the supplied configuration options * * @param array $config * @return Client|IntercomBasicAuthClient */ public static function factory($config = array()) { $client = new self(); $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required); $client->configure($config); $client->setBasicAuth($config->get('app_id'), $config->get('api_key')); $client->setUserAgent('intercom-php/1.4.0', true); return $client; }
/** * Creates a client token auth client with the supplied configuration options * * @param array $config * @return Client|IntercomBasicAuthClient */ public static function factory($config = []) { $client = new self(); $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required); $client->configure($config); $client->setBasicAuth($config->get('client_uuid'), $config->get('client_key')); $client->setUserAgent('intercom-php/1.2.3', true); $client->setDefaultOption('query/app_id', $config->get('app_id')); return $client; }
/** * Creates a new instance of this class or one of the specialized sub-classes. * * @todo replace the switch statement with an intelligent container / plugin system. * * @param string $namespace Namespace where this tag occurs. * @param string[] $namespace_aliases aliases used for all namespaces at the location of this tag. * @param SimpleXMLElement $xml root xml element for this tag. * @param DocBlox_Reflection_DocBlock_Tag $tag The actual tag as reflected. * * @return DocBlox_Parser_DocBlock_Tag_Definition */ public static function create($namespace, $namespace_aliases, SimpleXMLElement $xml, DocBlox_Reflection_DocBlock_Tag $tag) { switch ($tag->getName()) { case 'param': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Param($namespace, $namespace_aliases, $xml, $tag); break; case 'link': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Link($namespace, $namespace_aliases, $xml, $tag); break; default: $def = new self($namespace, $namespace_aliases, $xml, $tag); break; } $def->configure(); return $def; }
public static function factory($config = []) { $client = new self(); $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required); $client->configure($config); $client->setUserAgent(self::USER_AGENT, true); self::$consumer_key = $config->get('consumer_key'); self::$consumer_secret = $config->get('consumer_secret'); self::$application_name = $config->get('application_name'); // add a listener to alter every requests and authenticate them through Semantria weird oAuth $client->getEventDispatcher()->addListener('command.before_send', function (Event $event) use($client) { $command = $event['command']; $request = $client->oAuthRequest($command->getRequest()); }); return $client; }
public function configure($metadata = array()) { if (array_key_exists('name', $metadata)) { $this->setName($metadata['name']); } if (array_key_exists('multiple', $metadata)) { $this->setMultiple($metadata['multiple']); } if (array_key_exists('options', $metadata)) { $this->setOptions($metadata['options']); if (array_key_exists('data_class', $metadata['options'])) { $this->setDataClass($metadata['options']['data_class']); } } if (array_key_exists('fields', $metadata)) { $metadata['fields'] = $this->updateSettingFields($metadata['fields']); $fields = array(); foreach ($metadata['fields'] as $field => $meta_field) { if (!array_key_exists('widget', $meta_field)) { continue; } switch (key($meta_field['widget'])) { case 'subform': $f = new self($field); $f->configure($meta_field['widget']['subform']['metadata']); $fields[$field] = $f; break; default: $fields[$field] = $meta_field['widget']; } } $this->setFields($fields); } if (array_key_exists('subforms', $metadata)) { $subforms = $metadata['subforms']; $this->setSubForms($subforms); } }
/** * @param array config */ static function instance($config = null) { $i = new self(); $i->configure($config); return $i; }
/** * Entry point method. Receives the following arguments from web.php: * <ol> * <li>The web root</li> * <li>The configuration directory</li> * <li>The server profile</li> * <li>The script URL</li> * </ol> * * @param string[] args */ public static function main(array $args) { $r = new self($args[0], $args[2]); $r->configure(new \util\Properties($args[1] . DIRECTORY_SEPARATOR . 'web.ini')); $r->run($args[3]); }
/** * Creates a new instance of this class or one of the specialized sub-classes. * * @param string $namespace Namespace * where this tag occurs. * @param string[] $namespace_aliases Aliases * used for all namespaces at the location of this tag. * @param \SimpleXMLElement $xml Root xml * element for this tag. * @param \phpDocumentor\Reflection\DocBlock\Tag $tag The * actual tag as reflected. * * @todo replace the switch statement with an intelligent container / * plugin system. * * @return Definition */ public static function create($namespace, $namespace_aliases, \SimpleXMLElement $xml, \phpDocumentor\Reflection\DocBlock\Tag $tag) { $tag_name = $tag->getName(); // check whether the tag name is namespaced and replace alias with full // name to get the FQCN form if (strpos($tag_name, '\\') !== false) { $tag_name = explode('\\', $tag_name); if (count($tag_name) > 1 && isset($namespace_aliases[$tag_name[0]])) { $tag_name[0] = $namespace_aliases[$tag_name[0]]; } $tag_name = implode('\\', $tag_name); if ($tag_name[0] != '\\') { $tag_name = '\\' . $tag_name; } } switch ($tag_name) { case 'property-write': case 'property-read': case 'property': case 'param': $def = new Param($namespace, $namespace_aliases, $xml, $tag); break; case 'see': $def = new See($namespace, $namespace_aliases, $xml, $tag); break; case 'method': $def = new Method($namespace, $namespace_aliases, $xml, $tag); break; case 'uses': $def = new Uses($namespace, $namespace_aliases, $xml, $tag); break; case 'covers': $def = new Covers($namespace, $namespace_aliases, $xml, $tag); break; case 'link': $def = new Link($namespace, $namespace_aliases, $xml, $tag); break; case '\\Doctrine\\ORM\\Mapping\\column': case '\\Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy': case '\\Doctrine\\ORM\\Mapping\\DiscriminatorColumn': case '\\Doctrine\\ORM\\Mapping\\DiscriminatorMap': case '\\Doctrine\\ORM\\Mapping\\Entity': case '\\Doctrine\\ORM\\Mapping\\GeneratedValue': case '\\Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks': case '\\Doctrine\\ORM\\Mapping\\Id': case '\\Doctrine\\ORM\\Mapping\\InheritanceType': case '\\Doctrine\\ORM\\Mapping\\JoinColumn': case '\\Doctrine\\ORM\\Mapping\\JoinTable': case '\\Doctrine\\ORM\\Mapping\\ManyToOne': case '\\Doctrine\\ORM\\Mapping\\ManyToMany': case '\\Doctrine\\ORM\\Mapping\\MappedSuperclass': case '\\Doctrine\\ORM\\Mapping\\OneToOne': case '\\Doctrine\\ORM\\Mapping\\OneToMany': case '\\Doctrine\\ORM\\Mapping\\OrderBy': case '\\Doctrine\\ORM\\Mapping\\PostLoad': case '\\Doctrine\\ORM\\Mapping\\PostPersist': case '\\Doctrine\\ORM\\Mapping\\PostRemove': case '\\Doctrine\\ORM\\Mapping\\PostUpdate': case '\\Doctrine\\ORM\\Mapping\\PrePersist': case '\\Doctrine\\ORM\\Mapping\\PreRemove': case '\\Doctrine\\ORM\\Mapping\\PreUpdate': case '\\Doctrine\\ORM\\Mapping\\SequenceGenerator': case '\\Doctrine\\ORM\\Mapping\\Table': case '\\Doctrine\\ORM\\Mapping\\UniqueConstraint': case '\\Doctrine\\ORM\\Mapping\\Version': case 'Column': case 'ChangeTrackingPolicy': case 'DiscriminatorColumn': case 'DiscriminatorMap': case 'Entity': case 'GeneratedValue': case 'HasLifecycleCallbacks': case 'Id': case 'InheritanceType': case 'JoinColumn': case 'JoinTable': case 'ManyToOne': case 'ManyToMany': case 'MappedSuperclass': case 'OneToOne': case 'OneToMany': case 'OrderBy': case 'PostLoad': case 'PostPersist': case 'PostRemove': case 'PostUpdate': case 'PrePersist': case 'PreRemove': case 'PreUpdate': case 'SequenceGenerator': case 'Table': case 'UniqueConstraint': case 'Version': $def = new Doctrine($namespace, $namespace_aliases, $xml, $tag); break; default: $def = new self($namespace, $namespace_aliases, $xml, $tag); break; } $def->configure(); return $def; }
/** * Creates a new instance of this class or one of the specialized sub-classes. * * @param string $namespace Namespace where * this tag occurs. * @param string[] $namespace_aliases Aliases used * for all namespaces at the location of this tag. * @param SimpleXMLElement $xml Root xml element * for this tag. * @param DocBlox_Reflection_DocBlock_Tag $tag The actual tag * as reflected. * * @todo replace the switch statement with an intelligent container / * plugin system. * * @return DocBlox_Parser_DocBlock_Tag_Definition */ public static function create($namespace, $namespace_aliases, SimpleXMLElement $xml, DocBlox_Reflection_DocBlock_Tag $tag) { $tag_name = $tag->getName(); // check whether the tag name is namespaced and replace alias with full // name to get the FQCN form if (strpos($tag_name, '\\') !== false) { $tag_name = explode('\\', $tag_name); if (count($tag_name) > 1 && isset($namespace_aliases[$tag_name[0]])) { $tag_name[0] = $namespace_aliases[$tag_name[0]]; } $tag_name = implode('\\', $tag_name); if ($tag_name[0] != '\\') { $tag_name = '\\' . $tag_name; } } $tag_name = strtolower($tag_name); switch ($tag_name) { case 'property-write': case 'property-read': case 'property': case 'param': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Param($namespace, $namespace_aliases, $xml, $tag); break; case 'see': $def = new DocBlox_Parser_DocBlock_Tag_Definition_See($namespace, $namespace_aliases, $xml, $tag); break; case 'method': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Method($namespace, $namespace_aliases, $xml, $tag); break; case 'uses': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Uses($namespace, $namespace_aliases, $xml, $tag); break; case 'link': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Link($namespace, $namespace_aliases, $xml, $tag); break; case '\\doctrine\\orm\\mapping\\column': case '\\doctrine\\orm\\mapping\\changetrackingpolicy': case '\\doctrine\\orm\\mapping\\discriminatorcolumn': case '\\doctrine\\orm\\mapping\\discriminatormap': case '\\doctrine\\orm\\mapping\\entity': case '\\doctrine\\orm\\mapping\\generatedvalue': case '\\doctrine\\orm\\mapping\\haslifecyclecallbacks': case '\\doctrine\\orm\\mapping\\id': case '\\doctrine\\orm\\mapping\\inheritancetype': case '\\doctrine\\orm\\mapping\\joincolumn': case '\\doctrine\\orm\\mapping\\jointable': case '\\doctrine\\orm\\mapping\\manytoone': case '\\doctrine\\orm\\mapping\\manytomany': case '\\doctrine\\orm\\mapping\\mappedsuperclass': case '\\doctrine\\orm\\mapping\\onetoone': case '\\doctrine\\orm\\mapping\\onetomany': case '\\doctrine\\orm\\mapping\\orderby': case '\\doctrine\\orm\\mapping\\postload': case '\\doctrine\\orm\\mapping\\postpersist': case '\\doctrine\\orm\\mapping\\postremove': case '\\doctrine\\orm\\mapping\\postupdate': case '\\doctrine\\orm\\mapping\\prepersist': case '\\doctrine\\orm\\mapping\\preremove': case '\\doctrine\\orm\\mapping\\preupdate': case '\\doctrine\\orm\\mapping\\sequencegenerator': case '\\doctrine\\orm\\mapping\\table': case '\\doctrine\\orm\\mapping\\uniqueconstraint': case '\\doctrine\\orm\\mapping\\version': case 'column': case 'changetrackingpolicy': case 'discriminatorcolumn': case 'discriminatormap': case 'entity': case 'generatedvalue': case 'haslifecyclecallbacks': case 'id': case 'inheritancetype': case 'joincolumn': case 'jointable': case 'manytoone': case 'manytomany': case 'mappedsuperclass': case 'onetoone': case 'onetomany': case 'orderby': case 'postload': case 'postpersist': case 'postremove': case 'postupdate': case 'prepersist': case 'preremove': case 'preupdate': case 'sequencegenerator': case 'table': case 'uniqueconstraint': case 'version': $def = new DocBlox_Parser_DocBlock_Tag_Definition_Doctrine($namespace, $namespace_aliases, $xml, $tag); break; default: $def = new self($namespace, $namespace_aliases, $xml, $tag); break; } $def->configure(); return $def; }
/** * Override the ConfigurableTrait fromConfig method to handle custom classes for records * * @param array $options * * @return mixed */ public static function fromConfig(array $options = array()) { // Get the custom fetch class name if available $fetchClass = PhpOrient::getFetchClass(); if ($fetchClass) { $object = new $fetchClass(); } else { $object = new self(); } return $object->configure($options); }