/** * Creates a manipulator object from a file. * * @param string $file A file name * * @return sfClassManipulator A sfClassManipulator instance */ static public function fromFile($file) { $manipulator = new self(file_get_contents($file)); $manipulator->setFile($file); return $manipulator; }
static function createFromFile($file, $filename = null) { $f = pathinfo($file); $fileInfo = new self(); $fileInfo->setFile($file)->setMimeType(static::getMimeByExtension($f['extension']))->setFilename(!empty($filename) ? $filename : $f['filename'] . '.' . $f['extension']); return $fileInfo; }
public static function fromFile($file) { if (!is_readable($file)) { throw new Exception("{$file} is not readable"); } $set = new self(file_get_contents($file)); $set->setFile($file); return $set; }
public static function arrayWithFiles(array $files) { $filesArray = []; foreach ($files as $file) { $newFile = new self(); $newFile->setFile($file); $filesArray[] = $newFile; } return $filesArray; }
public static function createFromGlobals() { $request = new self(); $request->setGet(new ParameterBag($_GET)); $request->setPost(new ParameterBag($_POST)); $request->setCookie(new ParameterBag($_COOKIE)); $request->setSession(new ParameterBag($_SESSION)); $request->setServer(new ParameterBag($_SERVER)); $request->setFile(new ParameterBag($_FILES)); return $request; }
public function doClone($a_pool_id, $a_schedule_map = null) { $new_obj = new self(); $new_obj->setPoolId($a_pool_id); $new_obj->setTitle($this->getTitle()); $new_obj->setDescription($this->getDescription()); $new_obj->setNrOfItems($this->getNrOfItems()); $new_obj->setFile($this->getFile()); $new_obj->setPostText($this->getPostText()); $new_obj->setPostFile($this->getPostFile()); if ($a_schedule_map) { $schedule_id = $this->getScheduleId(); if ($schedule_id) { $new_obj->setScheduleId($a_schedule_map[$schedule_id]); } } $new_obj->save(); // files $source = $this->initStorage($this->getId()); $target = $new_obj->initStorage($new_obj->getId()); ilUtil::rCopy($source, $target); }
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; }
public function get($sPath = '', $bDebug = true) { $rResult =& $this->getValue($sPath, $bDebug); if (is_array($rResult)) { $rResult = new self($rResult, $this->getNS(), $this); // copy tokens $rResult->aTokens = $this->aTokens; $rResult->aResultTokens = $this->aResultTokens; if ($this->getFile()) { $rResult->setFile($this->getFile()); } } else { if (!is_object($rResult) && !is_null($rResult)) { if ($bDebug) { $this->throwException(sprintf('%s is not an array', $sPath), 3); } return null; } } return $rResult; }