本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::camelize方法的具体用法?PHP Container::camelize怎么用?PHP Container::camelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::camelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProxyFactoryCode
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';
if ($definition->isShared()) {
$instantiation .= " \$this->services['{$id}'] =";
}
if (func_num_args() >= 3) {
$methodName = func_get_arg(2);
} else {
@trigger_error(sprintf('You must use the third argument of %s to define the method to call to construct your service since version 3.1, not using it won\'t be supported in 4.0.', __METHOD__), E_USER_DEPRECATED);
$methodName = 'get' . Container::camelize($id) . 'Service';
}
$proxyClass = $this->getProxyClassName($definition);
$generatedClass = $this->generateProxyClass($definition);
$constructorCall = $generatedClass->hasMethod('staticProxyConstructor') ? $proxyClass . '::staticProxyConstructor' : 'new ' . $proxyClass;
return <<<EOF
if (\$lazyLoad) {
{$instantiation} {$constructorCall}(
function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) {
\$wrappedInstance = \$this->{$methodName}(false);
\$proxy->setProxyInitializer(null);
return true;
}
);
}
EOF;
}
示例2: getProxyFactoryCode
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';
if ($definition->isShared()) {
$instantiation .= " \$this->services['{$id}'] =";
}
$methodName = 'get' . Container::camelize($id) . 'Service';
$proxyClass = $this->getProxyClassName($definition);
return <<<EOF
if (\$lazyLoad) {
{$instantiation} new {$proxyClass}(
function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) {
\$wrappedInstance = \$this->{$methodName}(false);
\$proxy->setProxyInitializer(null);
return true;
}
);
}
EOF;
}
示例3: getProxyFactoryCode
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';
if ($definition->isShared()) {
$instantiation .= " \$this->services['{$id}'] =";
if (defined('Symfony\\Component\\DependencyInjection\\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope(false))) {
$instantiation .= " \$this->scopedServices['{$scope}']['{$id}'] =";
}
}
$methodName = 'get' . Container::camelize($id) . 'Service';
$proxyClass = $this->getProxyClassName($definition);
$generatedClass = $this->generateProxyClass($definition);
$constructorCall = $generatedClass->hasMethod('staticProxyConstructor') ? $proxyClass . '::staticProxyConstructor' : 'new ' . $proxyClass;
return <<<EOF
if (\$lazyLoad) {
\$container = \$this;
{$instantiation} {$constructorCall}(
function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) use (\$container) {
\$wrappedInstance = \$container->{$methodName}(false);
\$proxy->setProxyInitializer(null);
return true;
}
);
}
EOF;
}
示例4: getProxyFactoryCode
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';
if (ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
$instantiation .= " \$this->services['{$id}'] =";
} elseif (ContainerInterface::SCOPE_PROTOTYPE !== ($scope = $definition->getScope())) {
$instantiation .= " \$this->services['{$id}'] = \$this->scopedServices['{$scope}']['{$id}'] =";
}
$methodName = 'get' . Container::camelize($id) . 'Service';
$proxyClass = $this->getProxyClassName($definition);
return <<<EOF
if (\$lazyLoad) {
\$container = \$this;
{$instantiation} new {$proxyClass}(
function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) use (\$container) {
\$wrappedInstance = \$container->{$methodName}(false);
\$proxy->setProxyInitializer(null);
return true;
}
);
}
EOF;
}
示例5: __construct
/**
* Constructs a ViewsPluginManager object.
*
* @param string $type
* The plugin type, for example filter.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
$plugin_definition_annotation_name = 'Drupal\\views\\Annotation\\Views' . Container::camelize($type);
parent::__construct("Plugin/views/{$type}", $namespaces, $module_handler, 'Drupal\\views\\Plugin\\views\\ViewsPluginInterface', $plugin_definition_annotation_name);
$this->defaults += array('parent' => 'parent', 'plugin_type' => $type, 'register_theme' => TRUE);
$this->alterInfo('views_plugins_' . $type);
$this->setCacheBackend($cache_backend, "views:{$type}");
}
示例6: __construct
/**
* @inheritdoc
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
$plugin_definition_annotation_name = 'Drupal\\geocoder\\Annotation\\GeocoderPlugin';
parent::__construct('Plugin/Geocoder/' . Container::camelize($type), $namespaces, $module_handler, 'Drupal\\geocoder\\Plugin\\GeocoderPluginInterface', $plugin_definition_annotation_name);
$this->defaults += array('plugin_type' => strtolower($type));
$this->alterInfo('geocoder_plugins_' . $type);
$this->setCacheBackend($cache_backend, 'geocoder:' . $type);
}
示例7: __construct
public function __construct(array $defaults = array(), $router = null, $templateRoute = null)
{
$this->setRouter($router, $templateRoute);
foreach ($defaults as $key => $val) {
$method = 'set' . \Symfony\Component\DependencyInjection\Container::camelize($key);
$this->{$method}($val);
}
}
示例8: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
foreach ($this->context->getMetadata()->properties as $propertyMetadata) {
/* @var PropertyMetadata $propertyMetadata */
foreach ($propertyMetadata->getConstraints() as $constraint) {
if ($constraint instanceof ContentFile) {
$method = 'get' . Container::camelize($constraint->mapping) . 'MappingType';
if (!method_exists($value, $method)) {
throw new \RuntimeException(sprintf('Method "%s" should be defined in class %s', $method, get_class($value)));
}
$accessor = PropertyAccess::createPropertyAccessor();
$propertyName = $propertyMetadata->getPropertyName();
$content = $accessor->getValue($value, $propertyName);
// check also translations
if ($translations = $accessor->getValue($value, 'translations')) {
foreach ($translations as $translation) {
if ($translation->getField() == $propertyName) {
$content .= $translation->getContent();
}
}
}
$content = trim($content);
if (mb_strlen($content) == 0) {
return;
}
$mappingType = $value->{$method}();
$files = $this->contentFileManager->findFilesByMappingType($mappingType);
// extract all images from content property
preg_match_all('/src=[\'\\"]*(.+?)[\'\\"]/', $content, $matches);
array_shift($matches);
if (count($matches[0]) > 0) {
$matches = $matches[0];
foreach ($matches as $imgFile) {
$imgFile = preg_replace('/\\?.*$/', '', $imgFile);
$imgFile = pathinfo($imgFile, PATHINFO_BASENAME);
foreach ($files as $key => $file) {
/* @var \SciGroup\TinymcePluploadFileManagerBundle\Model\ContentFile $file */
if ($file->getFileName() == $imgFile) {
$file->setIsSubmitted(true);
unset($files[$key]);
continue 2;
}
}
// remove file
$pathResolver = $this->mappingResolver->resolve($mappingType);
$imgFile = $pathResolver->getDirectory(true) . '/' . $imgFile;
if (file_exists($imgFile)) {
unlink($imgFile);
}
}
}
foreach ($files as $file) {
$this->contentFileManager->remove($file);
}
}
}
}
}
示例9: __construct
/**
* {@inheritdoc}
*
* @param string $type
* The plugin type, for example 'color_selector'.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, $type, ConfigFactoryInterface $config_factory)
{
$path = Container::camelize($type);
$this->config = $config_factory->get('image_effects.settings');
parent::__construct("Plugin/image_effects/{$path}", $namespaces, $module_handler);
$this->alterInfo("image_effects_{$type}_plugin_info");
$this->setCacheBackend($cache_backend, "image_effects_{$type}_plugins");
$this->defaults += ['plugin_type' => $type];
}
示例10: __construct
/**
* Constructs a ViewsHandlerManager object.
*
* @param string $handler_type
* The plugin type, for example filter.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
* @param \Drupal\views\ViewsData $views_data
* The views data cache.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
$plugin_definition_annotation_name = 'Drupal\\views\\Annotation\\Views' . Container::camelize($handler_type);
parent::__construct("Plugin/views/{$handler_type}", $namespaces, $module_handler, $plugin_definition_annotation_name);
$this->setCacheBackend($cache_backend, "views:{$handler_type}", array('extension' => array(TRUE, 'views')));
$this->viewsData = $views_data;
$this->handlerType = $handler_type;
$this->defaults = array('plugin_type' => $handler_type);
}
示例11: getCodeBlocks
/** {@inheritdoc} */
public function getCodeBlocks()
{
// Convert keys to camelCase.
$config = [];
foreach ($this->config['resolve_loader'] as $key => $value) {
$config[lcfirst(Container::camelize($key))] = $value;
}
return [(new CodeBlock())->set(CodeBlock::RESOLVE_LOADER, $config)];
}
示例12: getCodeBlocks
/** {@inheritdoc} */
public function getCodeBlocks()
{
// Convert keys to camelCase.
$config = [];
foreach ($this->config['output'] as $key => $value) {
$config[lcfirst(Container::camelize($key))] = $value;
}
return [(new CodeBlock())->set(CodeBlock::OUTPUT, $config)];
}
示例13: process
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {
$className = strtr(Container::camelize($id), '_', '\\');
/** @var \Symfony\Component\DependencyInjection\Definition $definition */
if ($definition->getClass() === NULL && !$definition->isAbstract() && (class_exists($className) || interface_exists($className))) {
$definition->setClass($className);
}
}
}
示例14: getWhereSnippet
/**
* {@inheritdoc}
*/
public function getWhereSnippet(FilterDataInterface $filterData)
{
$values = $filterData->getValue();
$clauses = [];
$parameters = [];
foreach ($values as $value) {
$parameter = Container::camelize($this->getConfig()['field'] . '_' . $value);
$clauses[] = sprintf("%s = :%s", $this->getConfig()['field'], $parameter);
$parameters[$parameter] = $value;
}
return ['snippet' => '(' . implode(' OR ', $clauses) . ')', 'parameters' => $parameters];
}
示例15: camelizeKeys
private function camelizeKeys($array)
{
$result = [];
foreach ($array as $key => $value) {
$key = lcfirst(Container::camelize($key));
if (is_array($value)) {
$value = $this->camelizeKeys($value);
}
$result[$key] = $value;
}
return $result;
}