/** * @see \oat\oatbox\PhpSerializable::__toPhpCode() */ public function __toPhpCode() { $class = get_class($this); $name = $this->name; $url = $this->url; $rules = \common_Utils::toHumanReadablePhpString($this->getRules()); return "new {$class}(\n '{$name}',\n {$rules},\n '{$url}'\n )"; }
/** * Override the function to allow an additional header * * (non-PHPdoc) * @see common_persistence_PhpFileDriver::getContent() */ protected function getContent($key, $value) { $headerPath = $this->getExtension()->getDir() . 'config/header/' . $key . '.conf.php'; $header = file_exists($headerPath) ? file_get_contents($headerPath) : $this->getDefaultHeader($key); return $header . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL; }
/** * To configuration serialization * * @return string */ public function __toPhpCode() { $source = ''; if (!empty($this->readers)) { foreach ($this->readers as $reader) { $source .= \common_Utils::toHumanReadablePhpString($reader, 2) . PHP_EOL; } } $destination = ''; if (!empty($this->writers)) { foreach ($this->writers as $writer) { $destination .= \common_Utils::toHumanReadablePhpString($writer, 2) . PHP_EOL; } } $params = [self::CONFIG_SOURCE => $this->readers, self::CONFIG_DESTINATION => $this->writers]; return 'new ' . get_class($this) . '(' . \common_Utils::toHumanReadablePhpString($params, 1) . '),'; }
/** * Generate the php code that returns the provided value * * @param string $key * @param mixed $value * @return string */ protected function getContent($key, $value) { return $this->humanReadable ? "<?php return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL : "<?php return " . common_Utils::toPHPVariableString($value) . ";"; }
/** * (non-PHPdoc) * @see \oat\oatbox\PhpSerializable::__toPhpCode() */ public function __toPhpCode() { $options = $this->getOptions(); $params = empty($options) ? '' : \common_Utils::toHumanReadablePhpString($options); return 'new ' . get_class($this) . '(' . $params . ')'; }
/** * Override the function to allow an additional header * * (non-PHPdoc) * @see common_persistence_PhpFileDriver::getContent() */ protected function getContent($key, $value) { $headerPath = $this->getHeaderPath($key); $header = !is_null($headerPath) && file_exists($headerPath) ? file_get_contents($headerPath) : $this->getDefaultHeader($key); return $header . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL; }
protected function copyFile($file, $destination = null, $extra = array()) { $sample = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $file . '.sample'); $destination = $this->getDestinationDirectory() . (is_null($destination) ? $file : $destination); if (!file_exists(dirname($destination))) { mkdir(dirname($destination), 0770, true); } $map = array('{id}' => $this->id, '{name}' => self::escape($this->label), '{version}' => self::escape($this->version), '{author}' => self::escape($this->author), '{license}' => self::escape($this->license), '{description}' => self::escape($this->description), '{authorNs}' => $this->authorNamespace, '{dependencies}' => 'array(\'' . implode('\',\'', array_keys($this->requires)) . '\')', '{requires}' => \common_Utils::toHumanReadablePhpString($this->requires, 1), '{managementRole}' => GENERIS_NS . '#' . $this->id . 'Manager', '{licenseBlock}' => $this->getLicense(), '{installScripts}' => $this->substituteConstantTemplates(\common_Utils::toHumanReadablePhpString($this->installScripts, 1)), '{devtools}' => \common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDevTools')); $map = array_merge($map, $extra); $content = str_replace(array_keys($map), array_values($map), $sample); return file_put_contents($destination, $content); }
/** * Configuration serialization * * @return array */ public function __toPhpCode() { $options = array('key' => $this->key); return empty($options) ? '' : \common_Utils::toHumanReadablePhpString($options); }