/** * Wrapper for creating a support group. * It will check if the support group doesn't exist yet, if the tag or name already exists then NAME_TAKEN or TAG_TAKEN will be returned. * If the name is bigger than 20 characters or smaller than 4 and the tag greater than 7 or smaller than 2 a SIZE_ERROR will be returned. * Else it will return SUCCESS * @return a string that specifies if it was a success or not (SUCCESS, SIZE_ERROR, NAME_TAKEN or TAG_TAKEN ) */ public static function createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password) { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if (strlen($name) <= 21 && strlen($name) >= 4 && strlen($tag) <= 8 && strlen($tag) >= 2) { $notExists = self::supportGroup_EntryNotExists($name, $tag); //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if ($notExists == "SUCCESS") { $sGroup = new self(); $values = array('Name' => $name, 'Tag' => $tag, 'GroupEmail' => $groupemail, 'IMAP_MailServer' => $imap_mailserver, 'IMAP_Username' => $imap_username, 'IMAP_Password' => $imap_password); $sGroup->setName($values['Name']); $sGroup->setTag($values['Tag']); $sGroup->setGroupEmail($values['GroupEmail']); $sGroup->setIMAP_MailServer($values['IMAP_MailServer']); $sGroup->setIMAP_Username($values['IMAP_Username']); //encrypt password! global $cfg; $crypter = new MyCrypt($cfg['crypt']); $enc_password = $crypter->encrypt($values['IMAP_Password']); $sGroup->setIMAP_Password($enc_password); $sGroup->create(); //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); } else { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //return NAME_TAKEN or TAG_TAKEN return $notExists; } } else { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //RETURN ERROR that indicates SIZE return "SIZE_ERROR"; } }
/** * @param SimpleXMLElement $xml * * @return Product */ public static function createFromXML(SimpleXMLElement $xml) { /* <product default="true" name="bpack 24/7"> <price price20To30="750" price10To20="650" price5To10="550" price2To5="450" priceLessThan2="350" countryIso2Code="BE"/> <option visiblity="NOT_VISIBLE_BY_CONSUMER_OPTIONAL" price="0" name="Saturday"/> <option visiblity="NOT_VISIBLE_BY_CONSUMER_OPTIONAL" price="0" name="Info "Distributed""/> <option visiblity="NOT_VISIBLE_BY_CONSUMER_OPTIONAL" price="0" name="Insurance"/> </product> */ $attributes = $xml->attributes(); $children = $xml->children(); $product = new self(); $product->setDefault($attributes['default'] == 'true'); $product->setName($attributes['name']); if (isset($children->price)) { foreach ($children->price as $priceXml) { $product->addPrice(Price::createFromXML($priceXml)); } } if (isset($children->option)) { foreach ($children->option as $optionXml) { $product->addOption(Option::createFromXML($optionXml)); } } return $product; }
public static function newInstance($name, $container) { $instance = new self(); $instance->setName($name); $instance->setContainer($container); return $instance; }
/** * fromReflection() * * @param Zend_Reflection_Property $reflectionProperty * @return Zend_CodeGenerator_Php_Property */ public static function fromReflection(Zend_Reflection_Property $reflectionProperty) { $property = new self(); $property->setName($reflectionProperty->getName()); $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]); if ($reflectionProperty->getDocComment() != '') { $property->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionProperty->getDocComment())); } if ($reflectionProperty->isStatic()) { $property->setStatic(true); } if ($reflectionProperty->isPrivate()) { $property->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionProperty->isProtected()) { $property->setVisibility(self::VISIBILITY_PROTECTED); } else { $property->setVisibility(self::VISIBILITY_PUBLIC); } $property->setSourceDirty(false); return $property; }
/** * fromReflection() * * @param MethodReflection $reflectionMethod * @return MethodGenerator */ public static function fromReflection(MethodReflection $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter)); } $method->setBody($reflectionMethod->getBody()); return $method; }
public static function fromReflection(ZendL_Reflection_Class $reflectionClass) { $class = new self(); $class->setSourceContent($class->getSourceContent()); $class->setSourceDirty(false); if ($reflectionClass->getDocComment() != '') { $class->setDocblock(ZendL_Tool_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock())); } $class->setAbstract($reflectionClass->isAbstract()); $class->setName($reflectionClass->getName()); if ($parentClass = $reflectionClass->getParentClass()) { $class->setExtendedClass($parentClass->getName()); } $class->setImplementedInterfaces($reflectionClass->getInterfaceNames()); $properties = array(); foreach ($reflectionClass->getProperties() as $reflectionProperty) { if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) { $properties[] = ZendL_Tool_CodeGenerator_Php_Property::fromReflection($reflectionProperty); } } $class->setProperties($properties); $methods = array(); foreach ($reflectionClass->getMethods() as $reflectionMethod) { if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) { $methods[] = ZendL_Tool_CodeGenerator_Php_Method::fromReflection($reflectionMethod); } } $class->setMethods($methods); return $class; }
/** * Creates a new Guild object with attributes * * @param $name string Name of the guild * @param $banner string Banner of the guild * @return Guild The newly created guild */ public static function withAttributes($name, $banner) { $instance = new self(); $instance->setName($name); $instance->setBanner($banner); return $instance; }
public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $body = $reflectionMethod->getBody(); $body2 = str_replace("\n\n", "\n", $body); $body2 = preg_replace("|^\n\\s{4}|muU", "\n", $body2); $body2 = preg_replace("|^\\s{4}|muU", "", $body2); // $body2 = str_replace(' ', '.', $body2); //dmDebug::kill($body, "\n".$body2); $method->setBody($body2); return $method; }
/** * @param array $data * * @return Route */ public static function __set_state($data) { $route = new self($data['pattern'], $data['callback'], $data['args'], $data['requirements']); if (isset($data['name'])) { $route->setName($data['name']); } return $route; }
/** * fromReflection() * * @param Zend_Reflection_Docblock_Tag $reflectionTagReturn * @return Zend_CodeGenerator_Php_Docblock_Tag_License */ public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagLicense) { $returnTag = new self(); $returnTag->setName('license'); $returnTag->setUrl($reflectionTagLicense->getUrl()); $returnTag->setDescription($reflectionTagLicense->getDescription()); return $returnTag; }
public static function initWithArray($array) { $instance = new self(NULL, NULL, NULL); $instance->setName($array[EventCategory::EVENTCATEGORY_NAME]); $instance->setId($array[EventCategory::EVENTCATEGORY_ID]); $instance->setPar_cat($array[EventCategory::EVENTCATEGORY_PAR_CAT]); return $instance; }
/** * fromReflection() * * @param \Zend\Code\Reflection\ReflectionDocblockTag $reflectionTagReturn * @return \Zend\Code\Generator\DocBlock\Tag\ReturnTag */ public static function fromReflection(\Zend\Code\Reflection\DocBlock\TagInterface $reflectionTagReturn) { $returnTag = new self(); $returnTag->setName('return'); $returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename $returnTag->setDescription($reflectionTagReturn->getDescription()); return $returnTag; }
/** * fromReflection() * * @param Zend_Reflection_Docblock_Tag $reflectionTagReturn * @return Zend_CodeGenerator_Php_Docblock_Tag_Return */ public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagReturn) { $returnTag = new self(); $returnTag->setName('return'); $returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename $returnTag->setDescription($reflectionTagReturn->getDescription()); return $returnTag; }
/** * Criar Item com campos obrigatórios preenchidos * * @param string $id - Código do Produto * @param string $name - Nome do Produto * @param float $value - Valor Unitário * @param integer $quantity - Quantidade * * @return Item */ public static function create($id, $name, $value, $quantity) { $instance = new self(); $instance->setId($id); $instance->setName($name); $instance->setValue($value); $instance->setQuantity($quantity); return $instance; }
/** * @param $name * @return Model\Tool\CustomReport\Config * @throws \Exception */ public static function getByName($name) { $code = new self(); $code->setName($name); if (!$code->load()) { throw new \Exception("sql report definition : " . $name . " does not exist"); } return $code; }
/** * @static * @param $name * @return Tool_Tag_Config */ public static function getByName($name) { $tag = new self(); $tag->setName($name); if (!$tag->load()) { throw new Exception("tag definition : " . $name . " does not exist"); } return $tag; }
/** * @static * @param $name * @return Asset_Image_Thumbnail_Config */ public static function getByName($name) { $pipe = new self(); $pipe->setName($name); if (!$pipe->load()) { throw new Exception("video thumbnail definition : " . $name . " does not exist"); } return $pipe; }
/** * {@inheritDoc} */ public static function buildFromResponse(stdClass $response) { $bank = new self(); $bank->setCode(isset($response->code) ? $response->code : null); $bank->setName(isset($response->name) ? $response->name : null); $bank->setLogoUrl(isset($response->logo) ? $response->logo : null); $bank->raw = $response; return $bank; }
/** * @return Config */ public static function getPreviewConfig() { $config = new self(); $config->setName("pimcore-system-treepreview"); $config->setAudioBitrate(128); $config->setVideoBitrate(700); $config->setItems(array(array("method" => "scaleByWidth", "arguments" => array("width" => 500)))); return $config; }
/** * @param $name * @return Config * @throws \Exception */ public static function getByName($name) { $letter = new self(); $letter->setName($name); if (!$letter->load()) { throw new \Exception("newsletter definition : " . $name . " does not exist"); } return $letter; }
/** * Build Artsit with URI and name * @access public * @static * @param string $uri Artist URI * @param string $name Artist name * @return Artist */ public static function build($uri, $name) { // create Artist instance $artistItem = new self(); // update informations $artistItem->setUri((string) $uri); $artistItem->setName((string) $name); // return artist instance return $artistItem; }
public static function createFromArray(array $data) { $movement = new self(); $movement->setId(isset($data['id']) ? $data['id'] : null); $movement->setDate(new \DateTime($data['date'])); $movement->setAmount(new \InFog\SimpleFinance\Types\Money($data['amount'])); $movement->setName(new \InFog\SimpleFinance\Types\SmallString($data['name'])); $movement->setDescription(new \InFog\SimpleFinance\Types\Text($data['description'])); return $movement; }
/** * @param CurrencyEntity $currency * @return Currency */ public static function createFromCurrencyEntity(CurrencyEntity $currency) { $struct = new self(); $struct->setId($currency->getId()); $struct->setName($currency->getName()); $struct->setCurrency($currency->getCurrency()); $struct->setFactor($currency->getFactor()); $struct->setSymbol($currency->getSymbol()); return $struct; }
/** * fromReflection() * * @param Zend_Reflection_Docblock_Tag $reflectionTagParam * @return Zend_CodeGenerator_Php_Docblock_Tag */ public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagParam) { $paramTag = new self(); $paramTag->setName('param'); $paramTag->setDatatype($reflectionTagParam->getType()); // @todo rename $paramTag->setParamName($reflectionTagParam->getVariableName()); $paramTag->setDescription($reflectionTagParam->getDescription()); return $paramTag; }
/** * @param $name * @return GroupConfig */ public static function getByName($name) { try { $config = new self(); $config->setName($name); $config->getResource()->getByName(); return $config; } catch (\Exception $e) { } }
public static function __set_state($array) { $businessEntity = new self(); $businessEntity->setId($array['id']); $businessEntity->setClass($array['class']); $businessEntity->setName($array['name']); $businessEntity->setBusinessProperties($array['businessProperties']); $businessEntity->setDisable($array['disable']); return $businessEntity; }
/** * @param string $name * @param string $condition * @param string $action * @param int $priority * @param string $description * * @return Rule */ public static function factory($name, $condition, $action, $priority = 0, $description = '') { $rule = new self(); $rule->setName($name); $rule->setCondition($condition); $rule->setAction($action); $rule->setPriority($priority); $rule->setDescription($description); return $rule; }
/** * Creates a stuff with attributes * * @param $owner Charac The stuff owner * @param $name string Name of the stuff * @param $rarity integer Rarity of the stuff * @param $level integer Level of the stuff * @param $weight integer Weight of the stuff * @return Stuff The newly created stuff */ public static function withAttributes($owner, $name, $rarity, $level, $weight) { $instance = new self(); $instance->setOwner($owner); $instance->setName($name); $instance->setRarity($rarity); $instance->setLevel($level); $instance->setWeight($weight); return $instance; }
public static function initWithArray($array) { $instance = new self(NULL, NULL, NULL, NULL, NULL); $instance->setName($array[Location::LOCATION_NAME]); $instance->setId($array[Location::LOCATION_ID]); $instance->setLattitude($array[Location::LOCATION_LATTITUDE]); $instance->setLongitude($array[Location::LOCATION_LONGITUDE]); $instance->setType($array[Location::LOCATION_TYPE]); return $instance; }
/** * @param $name * @return GroupConfig */ public static function getByName($name, $storeId = 1) { try { $config = new self(); $config->setName($name); $config->setStoreId($storeId ? $storeId : 1); $config->getDao()->getByName(); return $config; } catch (\Exception $e) { } }