本文整理汇总了PHP中Puli\Manager\Assert\Assert::isArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isArray方法的具体用法?PHP Assert::isArray怎么用?PHP Assert::isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Puli\Manager\Assert\Assert
的用法示例。
在下文中一共展示了Assert::isArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
$options = array_replace_recursive(self::$defaultOptions, $options);
if (!isset($options['path'])) {
$options['path'] = $targetMethod->getClass()->getDirectory() . '/path-mappings.json';
}
Assert::stringNotEmpty($options['path'], 'The "path" option should be a non-empty string. Got: %s');
Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
Assert::boolean($options['optimize'], 'The "optimize" option should be a boolean. Got: %s');
Assert::isArray($options['change-stream'], 'The "change-stream" option should be an array. Got: %s');
$path = Path::makeAbsolute($options['path'], $options['root-dir']);
$relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
$relBaseDir = Path::makeRelative($options['root-dir'], $targetMethod->getClass()->getDirectory());
$escPath = '__DIR__.' . var_export('/' . $relPath, true);
$escBaseDir = $relBaseDir ? '__DIR__.' . var_export('/' . $relBaseDir, true) : '__DIR__';
if ($options['optimize']) {
$streamGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::CHANGE_STREAM, $options['change-stream']['type']);
$streamOptions = $options['change-stream'];
$streamOptions['root-dir'] = $options['root-dir'];
$streamGenerator->generateNewInstance('stream', $targetMethod, $generatorRegistry, $streamOptions);
$targetMethod->getClass()->addImport(new Import('Puli\\Repository\\OptimizedJsonRepository'));
$targetMethod->addBody(sprintf('$%s = new OptimizedJsonRepository(%s, %s, false, $stream);', $varName, $escPath, $escBaseDir));
} else {
$targetMethod->getClass()->addImport(new Import('Puli\\Repository\\JsonRepository'));
$targetMethod->addBody(sprintf('$%s = new JsonRepository(%s, %s, true);', $varName, $escPath, $escBaseDir));
}
}
示例2: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
$options = array_replace_recursive(self::$defaultOptions, $options);
Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
Assert::isArray($options['store'], 'The "store" option should be an array. Got: %s');
if (!isset($options['store']['path'])) {
$options['store']['path'] = $targetMethod->getClass()->getDirectory() . '/change-stream.json';
}
$kvsGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::KEY_VALUE_STORE, $options['store']['type']);
$kvsOptions = $options['store'];
$kvsOptions['root-dir'] = $options['root-dir'];
$kvsGenerator->generateNewInstance('store', $targetMethod, $generatorRegistry, $kvsOptions);
$targetMethod->getClass()->addImport(new Import('Puli\\Repository\\ChangeStream\\KeyValueStoreChangeStream'));
$targetMethod->addBody(sprintf('$%s = new KeyValueStoreChangeStream($store);', $varName));
}
示例3: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
$options = array_replace_recursive(self::$defaultOptions, $options);
Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
Assert::isArray($options['store'], 'The "store" option should be an array. Got: %s');
if (!isset($options['store']['path'])) {
$options['store']['path'] = $targetMethod->getClass()->getDirectory() . '/bindings.json';
}
$kvsGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::KEY_VALUE_STORE, $options['store']['type']);
$kvsOptions = $options['store'];
$kvsOptions['root-dir'] = $options['root-dir'];
$kvsGenerator->generateNewInstance('store', $targetMethod, $generatorRegistry, $kvsOptions);
$targetMethod->getClass()->addImport(new Import('Puli\\Discovery\\KeyValueStoreDiscovery'));
$targetMethod->getClass()->addImport(new Import('Puli\\Discovery\\Binding\\Initializer\\ResourceBindingInitializer'));
$targetMethod->addBody(sprintf("\$%s = new KeyValueStoreDiscovery(\$store, array(\n new ResourceBindingInitializer(\$repo),\n));", $varName));
}