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; }
/** * Enter description here... * * @param ZendL_Reflection_File $reflectionFile * @return ZendL_Tool_CodeGenerator_Php_File */ public static function fromReflection(ZendL_Reflection_File $reflectionFile) { $file = new self(); $file->setSourceContent($reflectionFile->getContents()); $file->setSourceDirty(false); $body = $reflectionFile->getContents(); // @todo this whole area needs to be reworked with respect to how body lines are processed foreach ($reflectionFile->getClasses() as $class) { $file->setClass(ZendL_Tool_CodeGenerator_Php_Class::fromReflection($class)); $classStartLine = $class->getStartLine(true); $classEndLine = $class->getEndLine(); $bodyLines = explode("\n", $body); $bodyReturn = array(); for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) { if ($lineNum == $classStartLine) { $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass); //'/* ZendL_Tool_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */'; $lineNum = $classEndLine; } else { $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion } } $body = implode("\n", $bodyReturn); unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); } if ($docblock = $reflectionFile->getDocblock()) { $file->setDocblock(ZendL_Tool_CodeGenerator_Php_Docblock::fromReflection($docblock)); $bodyLines = explode("\n", $body); $bodyReturn = array(); for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) { if ($lineNum == $docblock->getStartLine()) { $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock); //'/* ZendL_Tool_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */'; $lineNum = $docblock->getEndLine(); } else { $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion } } $body = implode("\n", $bodyReturn); unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); } $file->setBody($body); return $file; }
static function fromArray(array $a_def) { // The array must have a name and class. Or else... if (!isset($a_def['name'])) { throw new exceptions\HttpInternalServerError("Name undefined in dependency definition"); } if (!isset($a_def['class'])) { throw new exceptions\HttpInternalServerError("Class name undefined in dependency definition '" . $a_def['name'] . "'"); } $def = new self(); $def->setName($a_def['name']); $def->setClass($a_def['class']); if (isset($a_def['dependencies'])) { $def->setDependencies($a_def['dependencies']); } if (isset($a_def['mother'])) { $def->setMother($a_def['mother']); } if (isset($a_def['type'])) { $def->setType($a_def['type']); } return $def; }
/** * Creates a character with attributes * * @param $name string Name of the character * @param $level integer Level of the character * @param $class string Class of the character * @param $race string Race of the character * @param $gender string Gender of the character * @return Charac The newly created instance of Charac */ public static function withAttributes($name, $level, $class, $race, $gender) { $instance = new self(); $instance->setName($name); $instance->setLevel($level); $instance->setClass($class); $instance->setRace($race); $instance->setGender($gender); return $instance; }
/** * Creates a CronJobDefinition from a Array $job * provided by the parser $parser * * @param Array $xml * @param CronJobParser $parser * * @return CronJobDefinition */ public static function fromArray(array $job, CronJobParser $parser) { // create and return object $obj = new self(); $obj->setParser($parser); $obj->setName($job["name"]); $obj->setForkable((bool) $job["forkable"]); $obj->setInterval($job["interval"]); $obj->setPath($job["path"]); $obj->setClass($job["class"]); $obj->setStartTime($job["starttime"]); $obj->setEndTime($job["endtime"]); $obj->setArguments($job["args"]); $obj->setWeekDays($job["weekdays"]); $obj->setSuspended((bool) $job["suspended"]); if (isset($job["lastrun"])) { $obj->setLastExec($job["lastrun"]); } else { $obj->setLastExec(0); } return $obj; }
public static function create(\Exception $exception, $statusCode = null, array $headers = array()) { $e = new self(); $e->setMessage($exception->getMessage()); $e->setCode($exception->getCode()); if (null === $statusCode) { $statusCode = 500; } $e->setStatusCode($statusCode); $e->setHeaders($headers); $e->setTraceFromException($exception); $e->setClass(get_class($exception)); $e->setFile($exception->getFile()); $e->setLine($exception->getLine()); if ($exception->getPrevious()) { $e->setPrevious(self::create($exception->getPrevious())); } return $e; }