_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q246200 | XmlRenderListener.detach | validation | public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
/* @var SharedEventManager $sharedEvents */
$sharedEvents = $events->getSharedManager();
foreach ($this->sharedListeners as $index => $listener) {
if ($sharedEvents->detach($listener)) {
unset($this->sharedListeners[$index]);
}
}
} | php | {
"resource": ""
} |
q246201 | Form.render | validation | public function render(FormInterface $form, $layout = self::LAYOUT_HORIZONTAL, $parameter = array())
{
/* @var $renderer \Zend\View\Renderer\PhpRenderer */
$formContent = $this->renderBare($form, $layout, $parameter);
$renderer = $this->getView();
if ($form instanceof DescriptionAwareFormInterface && $form->isDescriptionsEnabled()) {
/* @var $form DescriptionAwareFormInterface|FormInterface */
$renderer->headscript()->appendFile(
$renderer->basepath('modules/Core/js/forms.descriptions.js')
);
if ($desc = $form->getOption('description', '')) {
$descriptionParams=$form->getOption('description_params');
$translator = $this->getTranslator();
$textDomain = $this->getTranslatorTextDomain();
$desc = $translator->translate($desc, $textDomain);
if ($descriptionParams) {
array_unshift($descriptionParams, $desc);
$desc = call_user_func_array('sprintf', $descriptionParams);
}
}
$formContent = sprintf(
'<div class="daf-form-container row">
<div class="daf-form col-md-8"><div class="panel panel-default"><div class="panel-body">%s</div></div></div>
<div class="daf-desc col-md-4">
<div class="daf-desc-content alert alert-info">%s</div>
</div>
</div>',
$formContent,
$desc
);
} else {
$formContent = '<div class="form-content">' . $formContent . '</div>';
}
$markup = '<div id="form-%s" class="form-container">'
. '%s'
. '%s'
. '</div>';
if ($label = $form->getLabel()) {
$label = '<div class="form-headline"><h3>' . $renderer->translate($label) . '</h3></div>';
}
return sprintf(
$markup,
$form->getAttribute('id') ?: $form->getName(),
$label,
$formContent
);
} | php | {
"resource": ""
} |
q246202 | FormEvent.setForm | validation | public function setForm($form)
{
if (!$form instanceof FormInterface && !$form instanceof Container) {
throw new \InvalidArgumentException('Form must either implement \Zend\Form\FormInterface or extend from \Core\Form\Container');
}
$this->form = $form;
return $this;
} | php | {
"resource": ""
} |
q246203 | AdminControllerEvent.addViewModel | validation | public function addViewModel($name, $model, $priority=0)
{
$this->models->insert($name, $model, $priority);
return $this;
} | php | {
"resource": ""
} |
q246204 | AdminControllerEvent.addViewTemplate | validation | public function addViewTemplate($name, $template, $vars = [], $priority = 0)
{
if (is_int($vars)) {
$priority = $vars;
$vars = [];
}
$model = new ViewModel($vars);
$model->setTemplate($template);
return $this->addViewModel($name, $model, $priority);
} | php | {
"resource": ""
} |
q246205 | AdminControllerEvent.addViewVariables | validation | public function addViewVariables($name, $data = [], $priority = 0)
{
if (is_array($name)) {
if (!isset($name['name'])) {
throw new \DomainException('Key "name" must be specified, if array is passed as first parameter.');
}
if (is_int($data)) {
$priority = $data;
}
$data = $name;
$name = $data['name'];
} elseif (is_int($data)) {
$priority = $data;
$data = [];
}
if (!isset($data['name'])) {
$data['name'] = $name;
}
return $this->addViewTemplate($name, "core/admin/dashboard-widget", $data, $priority);
} | php | {
"resource": ""
} |
q246206 | Params.fromFiles | validation | public function fromFiles($name = null, $default = null)
{
if ($name === null) {
return $this->event->getRequest()->getFiles($name, $default)->toArray();
}
return $this->event->getRequest()->getFiles($name, $default);
} | php | {
"resource": ""
} |
q246207 | Params.fromHeader | validation | public function fromHeader($header = null, $default = null)
{
if ($header === null) {
return $this->event->getRequest()->getHeaders($header, $default)->toArray();
}
return $this->event->getRequest()->getHeaders($header, $default);
} | php | {
"resource": ""
} |
q246208 | Params.fromPost | validation | public function fromPost($param = null, $default = null)
{
if ($param === null) {
return $this->event->getRequest()->getPost($param, $default)->toArray();
}
return $this->event->getRequest()->getPost($param, $default);
} | php | {
"resource": ""
} |
q246209 | Params.fromQuery | validation | public function fromQuery($param = null, $default = null)
{
if ($param === null) {
return $this->event->getRequest()->getQuery($param, $default)->toArray();
}
return $this->event->getRequest()->getQuery($param, $default);
} | php | {
"resource": ""
} |
q246210 | Params.fromEvent | validation | public function fromEvent($param = null, $default = null)
{
if (null === $param) {
return $this->event->getParams();
}
return $this->event->getParam($param, $default);
} | php | {
"resource": ""
} |
q246211 | UniqueId.process | validation | public function process(array $event)
{
$event = parent::process($event);
$event['uniqueId'] = substr($event['extra']['requestId'], 0, 7);
unset($event['extra']['requestId']);
return $event;
} | php | {
"resource": ""
} |
q246212 | ContentItem.convert | validation | public static function convert(ContentItemInterface $from, ContentItemInterface $to)
{
$reflectionFrom = new \ReflectionClass($from);
$reflectionTo = new \ReflectionClass($to);
foreach ($reflectionFrom->getProperties() as $property) {
$property->setAccessible(true);
$method = 'set' . ucfirst($property->getName());
if ($reflectionTo->hasMethod($method)) {
$to->$method($property->getValue($from));
}
}
return $to;
} | php | {
"resource": ""
} |
q246213 | TreeHydrator.flattenTree | validation | private function flattenTree($tree, &$data, $curId = '1')
{
$data[] =
new \ArrayObject([
'id' => $tree->getId(),
'current' => $curId,
'name' => $tree->getName(),
'value' => $tree->getValue(),
'priority' => $tree->getPriority(),
'do' => 'nothing',
]);
if ($tree->hasChildren()) {
foreach ($tree->getChildren() as $i => $child) {
$this->flattenTree($child, $data, $curId . '-' . ($i + 1));
}
}
} | php | {
"resource": ""
} |
q246214 | TreeHydrator.prepareHydrateData | validation | private function prepareHydrateData(array $data)
{
/*
* unflatten tree
*/
$items = $data['items'];
$tree = [ '__root__' => array_shift($items) ];
foreach ($items as $item) {
$parent = substr($item['current'], 0, strrpos($item['current'], '-'));
$tree[$parent][] = $item;
}
$this->hydrateData = $tree;
} | php | {
"resource": ""
} |
q246215 | TreeHydrator.hydrateTree | validation | private function hydrateTree(NodeInterface $object, \ArrayObject $currentData = null)
{
if (null === $currentData) {
$currentData = $this->hydrateData['__root__'];
}
if ('set' == $currentData['do']) {
$object
->setName($currentData['name'])
->setValue($currentData['value'])
->setPriority($currentData['priority'])
;
}
if (isset($this->hydrateData[$currentData['current']])) {
foreach ($this->hydrateData[$currentData['current']] as $childData) {
$child = $this->findOrCreateChild($object, $childData['id']);
if ('remove' == $childData['do']) {
$object->removeChild($child);
} else {
$this->hydrateTree($child, $childData);
}
}
}
return $object;
} | php | {
"resource": ""
} |
q246216 | TreeHydrator.findOrCreateChild | validation | private function findOrCreateChild($tree, $id)
{
/* @var NodeInterface $node */
foreach ($tree->getChildren() as $node) {
if ($id && $node->getId() == $id) {
return $node;
}
}
$nodeClass = get_class($tree);
$node = new $nodeClass();
$tree->addChild($node);
return $node;
} | php | {
"resource": ""
} |
q246217 | AssetsInstallController.factory | validation | public static function factory(ContainerInterface $container)
{
/* @var ModuleManager $manager */
$manager = $container->get('ModuleManager');
$modules = $manager->getLoadedModules();
return new static($modules);
} | php | {
"resource": ""
} |
q246218 | FileTransport.send | validation | public function send(\Zend\Mail\Message $message)
{
$options = $this->options;
$filename = call_user_func($options->getCallback(), $this);
$file = $options->getPath() . DIRECTORY_SEPARATOR . $filename;
$contents = $message->toString();
$umask = umask();
umask(022);
if (false === file_put_contents($file, $contents, LOCK_EX)) {
throw new RuntimeException(sprintf(
'Unable to write mail to file (directory "%s")',
$options->getPath()
));
}
umask($umask);
$this->lastFile = $file;
} | php | {
"resource": ""
} |
q246219 | NameFilter.filter | validation | public function filter($value)
{
return isset($this->map[$value]) ? $this->map[$value] : $value;
} | php | {
"resource": ""
} |
q246220 | SearchForm.get | validation | public function get($form, $options = null, $params = null)
{
if (!is_object($form)) {
$form = $this->formElementManager->get($form, $options);
}
/** @noinspection PhpUndefinedMethodInspection */
$params = $params ?: clone $this->getController()->getRequest()->getQuery();
/* I tried using form methods (bind, isValid)...
* but because the search form could be in an invalidated state
* when the page is loaded, we need to hydrate the params manually.
*/
$hydrator = $form->getHydrator();
$data = $hydrator->extract($params);
$form->setData($data);
$hydrator->hydrate($data, $params);
return $form;
} | php | {
"resource": ""
} |
q246221 | TimezoneAwareDate.convertToDatabaseValue | validation | public function convertToDatabaseValue($value)
{
if (!$value instanceof \DateTime) {
return null;
}
$timezone = $value->getTimezone()->getName();
$timestamp = $value->getTimestamp();
$date = new \MongoDate($timestamp);
return array(
'date' => $date,
'tz' => $timezone,
);
} | php | {
"resource": ""
} |
q246222 | TimezoneAwareDate.convertToPhpValue | validation | public function convertToPhpValue($value)
{
if (!is_array($value)
|| !isset($value['date'])
|| !$value['date'] instanceof \MongoDate
|| !isset($value['tz'])
) {
return null;
}
$timestamp = $value['date']->sec;
$date = new \DateTime('@'.$timestamp);
$date->setTimezone(new \DateTimeZone($value['tz']));
return $date;
} | php | {
"resource": ""
} |
q246223 | FormEditor.setOptions | validation | public function setOptions($options)
{
foreach ($options as $key => $val) {
$this->setOption($key, $val);
}
} | php | {
"resource": ""
} |
q246224 | Container.getIterator | validation | public function getIterator()
{
$iterator = new PriorityList();
$iterator->isLIFO(false);
foreach ($this->activeForms as $key) {
$spec = $this->forms[$key];
$priority = isset($spec['priority']) ? $spec['priority'] : 0;
$iterator->insert($key, $this->getForm($key), $priority);
}
return $iterator;
} | php | {
"resource": ""
} |
q246225 | Container.setParams | validation | public function setParams(array $params)
{
$this->params = array_merge($this->params, $params);
foreach ($this->forms as $form) {
if (isset($form['__instance__'])
&& is_object($form['__instance__'])
&& method_exists($form['__instance__'], 'setParams')
) {
$form['__instance__']->setParams($params);
}
}
return $this;
} | php | {
"resource": ""
} |
q246226 | Container.setParam | validation | public function setParam($key, $value)
{
$this->params[$key] = $value;
foreach ($this->forms as $form) {
if (isset($form['__instance__'])
&& is_object($form['__instance__'])
&& method_exists($form['__instance__'], 'setParam')
) {
$form['__instance__']->setParam($key, $value);
}
}
return $this;
} | php | {
"resource": ""
} |
q246227 | Container.executeAction | validation | public function executeAction($name, array $data = [])
{
if (false !== strpos($name, '.')) {
list($name, $childKey) = explode('.', $name, 2);
$container = $this->getForm($name);
// execute child container's action
return $container->executeAction($childKey, $data);
}
// this container defines no actions
return [];
} | php | {
"resource": ""
} |
q246228 | Container.setForm | validation | public function setForm($key, $spec, $enabled = true)
{
if (is_object($spec)) {
if ($spec instanceof FormParentInterface) {
$spec->setParent($this);
}
$spec = [ '__instance__' => $spec, 'name' => $key, 'entity' => '*' ];
}
if (!is_array($spec)) {
$spec = array('type' => $spec, 'name' => $key);
}
if (!isset($spec['name'])) {
$spec['name'] = $key;
}
if (!isset($spec['entity'])) {
$spec['entity'] = '*';
}
$this->forms[$key] = $spec;
if ($enabled) {
$this->enableForm($key);
} elseif (true === $this->activeForms) {
$this->activeForms = false;
}
return $this;
} | php | {
"resource": ""
} |
q246229 | Container.setForms | validation | public function setForms(array $forms, $enabled = true)
{
foreach ($forms as $key => $spec) {
if (is_array($spec) && isset($spec['enabled'])) {
$currentEnabled = $spec['enabled'];
unset($spec['enabled']);
} else {
$currentEnabled = $enabled;
}
$this->setForm($key, $spec, $currentEnabled);
}
return $this;
} | php | {
"resource": ""
} |
q246230 | Container.enableForm | validation | public function enableForm($key = null)
{
if (null === $key) {
$this->activeForms = array_keys($this->forms);
return $this;
}
if (!is_array($key)) {
$key = array($key);
}
foreach ($key as $k) {
if (false !== strpos($k, '.')) {
// this seems not to be childkey.childform but actualkey.childkey
list($childKey, $childForm) = explode('.', $k, 2);
$child = $this->getForm($childKey);
$child->enableForm($childForm);
} else {
if (isset($this->forms[$k]) && !in_array($k, $this->activeForms)) {
$this->activeForms[] = $k;
}
}
}
return $this;
} | php | {
"resource": ""
} |
q246231 | Container.disableForm | validation | public function disableForm($key = null)
{
if (null === $key) {
$this->activeForms = array();
return $this;
}
if (!is_array($key)) {
$key = array($key);
}
foreach ($key as $k) {
if (false !== strpos($k, '.')) {
list($childKey, $childForm) = explode('.', $k, 2);
$child = $this->getForm($childKey);
$child->disableForm($childForm);
} elseif (isset($this->forms[$k]['__instance__'])) {
unset($this->forms[$k]['__instance__']);
}
}
$this->activeForms = array_filter(
$this->activeForms,
function ($item) use ($key) {
return !in_array($item, $key);
}
);
return $this;
} | php | {
"resource": ""
} |
q246232 | Container.getEntity | validation | public function getEntity($key='*')
{
return isset($this->entities[$key]) ? $this->entities[$key] : null;
} | php | {
"resource": ""
} |
q246233 | Container.mapEntity | validation | protected function mapEntity($form, $entity, $property)
{
if (false === $property) {
return;
}
if (true === $property) {
$mapEntity = $entity;
} elseif ($entity->hasProperty($property) || is_callable([$entity, "get$property"])) {
$getter = "get$property";
$mapEntity = $entity->$getter();
} else {
return;
}
if ($form instanceof Container) {
$form->setEntity($mapEntity);
} else {
$form->bind($mapEntity);
}
} | php | {
"resource": ""
} |
q246234 | Container.getActiveFormActual | validation | public function getActiveFormActual($setDefault = true)
{
$key = null;
if (!empty($this->activeForms)) {
$key = $this->activeForms[0];
}
if (!isset($key) && $setDefault) {
$formsAvailable = array_keys($this->forms);
$key = array_shift($formsAvailable);
}
return $key;
} | php | {
"resource": ""
} |
q246235 | Container.getActiveFormPrevious | validation | public function getActiveFormPrevious()
{
$key = null;
$actualKey = $this->getActiveFormActual();
if (isset($actualKey)) {
$forms = array_keys($this->forms);
$formsFlip = array_flip($forms);
$index = $formsFlip[$actualKey];
if (0 < $index) {
$key = $forms[$index-1];
}
}
return $key;
} | php | {
"resource": ""
} |
q246236 | Container.getActiveFormNext | validation | public function getActiveFormNext()
{
$key = null;
$actualKey = $this->getActiveFormActual();
if (isset($actualKey)) {
$forms = array_keys($this->forms);
$formsFlip = array_flip($forms);
$index = $formsFlip[$actualKey];
if ($index < count($forms) - 1) {
$key = $forms[$index+1];
}
}
return $key;
} | php | {
"resource": ""
} |
q246237 | SearchForm.getColumnMap | validation | public function getColumnMap()
{
$map = $this->getOption('column_map');
if (null === $map) {
$map = [];
foreach ($this as $element) {
$col = $element->getOption('span');
if (null !== $col) {
$map[$element->getName()] = $col;
}
}
$this->setOption('column_map', $map);
}
return $map;
} | php | {
"resource": ""
} |
q246238 | SearchForm.setSearchParams | validation | public function setSearchParams($params)
{
if ($params instanceof \Traversable) {
$params = ArrayUtils::iteratorToArray($params);
}
$params = Json::encode($params);
$this->setAttribute('data-search-params', $params);
return $this;
} | php | {
"resource": ""
} |
q246239 | ScheduledContentVoter.decide | validation | public static function decide(ScheduledContentInterface $object, array $attributes = [])
{
$now = new \DateTimeImmutable();
$vote = VoterInterface::ACCESS_ABSTAIN;
$from = $object->isScheduledFrom();
$till = $object->isScheduledTill();
if (!$object->isPublic() || false === self::notEmpty($from, $till)) {
return $vote;
}
switch (true) {
case is_null($from):
$vote = $till >= $now ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
break;
case is_null($till):
switch (true) {
case ($from <= $now):
$vote = VoterInterface::ACCESS_GRANTED;
break;
case ($from > $now && self::hasCmsAttribute($attributes)):
$vote = VoterInterface::ACCESS_GRANTED;
break;
default:
$vote = VoterInterface::ACCESS_DENIED;
}
break;
default:
switch (true) {
case ($from <= $now && $till >= $now):
$vote = VoterInterface::ACCESS_GRANTED;
break;
case (($from > $now && $till >= $now) && self::hasCmsAttribute($attributes)):
$vote = VoterInterface::ACCESS_GRANTED;
break;
default:
$vote = VoterInterface::ACCESS_DENIED;
}
}
return $vote;
} | php | {
"resource": ""
} |
q246240 | PageAdmin.fixOneToMany | validation | protected function fixOneToMany(PageInterface $object)
{
$items = $object->getContentItems();
if ($items) {
foreach ($object->getContentItems() as $item) {
$item->setPage($object);
}
}
if ($this->menuManager) {
$this->menuManager->flush();
}
} | php | {
"resource": ""
} |
q246241 | PageAdmin.preRemove | validation | public function preRemove($object)
{
if (!is_null($this->urlProvider) && !is_null($this->menuManager)) {
$url = $this->urlProvider->url($object);
$menuItem = $this->menuManager->getItem($url);
if ($menuItem instanceof MenuItem) {
$this->menuManager->removeItem($menuItem);
$this->menuManager->flush();
}
}
} | php | {
"resource": ""
} |
q246242 | PageAdmin.removeTab | validation | public function removeTab($tabName, FormMapper $formMapper)
{
$tabs = $this->getFormTabs();
if (array_key_exists($tabName, $tabs)) {
$groups = $this->getFormGroups();
if (!is_array($groups)) {
return;
}
foreach ($tabs[$tabName]['groups'] as $group) {
if (isset($groups[$group])) {
foreach ($groups[$group]['fields'] as $field) {
$formMapper->remove($field);
}
}
unset($groups[$group]);
}
$this->setFormGroups($groups);
$this->removeEmptyGroups();
}
} | php | {
"resource": ""
} |
q246243 | PageAdmin.removeEmptyGroups | validation | public function removeEmptyGroups()
{
$tabs = $this->getFormTabs();
if (!is_array($tabs)) {
return;
}
$groups = $this->getFormGroups();
foreach ($tabs as $tabKey => $tab) {
foreach ($tab['groups'] as $tabGroup) {
if (!array_key_exists($tabGroup, $groups)) {
unset($tabs[$tabKey]);
}
}
}
$this->setFormTabs($tabs);
} | php | {
"resource": ""
} |
q246244 | EventManagerAbstractFactory.getConfig | validation | protected function getConfig($services, $name)
{
$defaults = [
'service' => 'EventManager',
'configure' => true,
'identifiers' => [ $name ],
'event' => '\Zend\EventManager\Event',
'listeners' => [],
];
$config = $services->get('Config');
$config = isset($config['event_manager'][$name]) ? $config['event_manager'][$name] : [];
/*
* array_merge does not work, because the default values for 'identifiers' and 'listeners'
* are arrays and array_merge breaks the structure.
*/
$config = array_replace_recursive($defaults, $config);
return $config;
} | php | {
"resource": ""
} |
q246245 | EventManagerAbstractFactory.createEventManager | validation | protected function createEventManager($services, $config)
{
/* @var \Zend\EventManager\EventManagerInterface|\Core\EventManager\EventProviderInterface $events */
if ($services->has($config['service'])) {
$events = $services->get($config['service']);
} else {
if (!class_exists($config['service'], true)) {
throw new \UnexpectedValueException(sprintf(
'Class or service %s does not exists. Cannot create event manager instance.',
$config['service']
));
}
$events = new $config['service']();
}
if (false === $config['configure']) {
return $events;
}
$events->setIdentifiers($config['identifiers']);
/* @var \Zend\EventManager\EventInterface $event */
$event = $services->has($config['event']) ? $services->get($config['event']) : new $config['event']();
$events->setEventPrototype($event);
if ('EventManager' != $config['service'] && method_exists($events, 'setSharedManager') && $services->has('SharedEventManager')) {
/* @var \Zend\EventManager\SharedEventManagerInterface $sharedEvents */
$sharedEvents = $services->get('SharedEventManager');
$events->setSharedManager($sharedEvents);
}
return $events;
} | php | {
"resource": ""
} |
q246246 | EventManagerAbstractFactory.attachListeners | validation | protected function attachListeners($services, $eventManager, $listeners)
{
$lazyListeners = [];
foreach ($listeners as $name => $options) {
$options = $this->normalizeListenerOptions($name, $options);
if ($options['lazy'] && null !== $options['attach']) {
foreach ($options['attach'] as $spec) {
$lazyListeners[] = [
'service' => $options['service'],
'event' => $spec['event'],
'method' => $spec['method'],
'priority' => $spec['priority'],
];
}
continue;
}
if ($services->has($options['service'])) {
$listener = $services->get($options['service']);
} elseif (class_exists($options['service'], true)) {
$listener = new $options['service']();
} else {
throw new \UnexpectedValueException(sprintf(
'Class or service %s does not exists. Cannot create listener instance.',
$options['service']
));
}
if ($listener instanceof ListenerAggregateInterface) {
$listener->attach($eventManager, $options['priority']);
continue;
}
foreach ($options['attach'] as $spec) {
$callback = $spec['method'] ? [ $listener, $spec['method'] ] : $listener;
$eventManager->attach($spec['event'], $callback, $spec['priority']);
}
}
if (!empty($lazyListeners)) {
/* @var \Core\Listener\DeferredListenerAggregate $aggregate */
$aggregate = $services->get('Core/Listener/DeferredListenerAggregate');
$aggregate->setListeners($lazyListeners)
->attach($eventManager);
}
} | php | {
"resource": ""
} |
q246247 | EventManagerAbstractFactory.normalizeListenerOptions | validation | protected function normalizeListenerOptions($name, $options)
{
/*
* $options is an array with following meta-syntax:
*
* $options = [
* string:listener => string:event,
* string:listener => [ string|array:event{, string:methodName}{, int:priority}{, bool:lazy }],
* string:aggregate, // implies integer value as $name
* string:aggregate => int:priority,
* string:listener => [
* 'events' => [ 'event', 'event' => priority, 'event' => 'method',
* 'event' => [ 'method' => method, 'priority' => priority ],
* 'event' => [ 'method' => [ 'method', 'method' => priority ], 'priority' => priority ]
* ],
* 'method' => method,
* 'priority' => priority,
* 'lazy' => bool
* ]
*/
$normalized = [
'service' => $name,
'attach' => null,
'priority' => 1,
'lazy' => false,
];
if (is_int($name)) {
/* $options must be the name of an aggregate service or class. */
$normalized['service'] = $options;
return $normalized;
}
if (is_int($options)) {
/* $name must be the name of an aggregate and the priority is passed. */
$normalized['priority'] = $options;
return $normalized;
}
if (is_string($options)) {
/* Only an event name is provided in config */
$normalized['attach'] = [ [ 'event' => $options, 'method' => null, 'priority' => 1 ] ];
return $normalized;
}
if (ArrayUtils::isHashTable($options)) {
$normalized['attach'] = $this->normalizeEventsSpec($options);
if (isset($options['lazy'])) {
$normalized['lazy'] = $options['lazy'];
}
return $normalized;
}
$event = $method = null;
$priority = 1;
$lazy = false;
foreach ($options as $opt) {
if (is_array($opt)) {
/* Must be event names */
$event = $opt;
} elseif (is_string($opt)) {
if (null === $event) {
/* first string found is assumed to be the event name */
$event = [ $opt ];
} else {
/* second string found must be a method name. */
$method = $opt;
}
} elseif (is_int($opt)) {
/* Integer values must be priority */
$priority = $opt;
} elseif (is_bool($opt)) {
/* Lazy option is passed. */
$lazy = $opt;
}
}
foreach ($event as &$eventSpec) {
$eventSpec = [ 'event' => $eventSpec, 'method' => $method, 'priority' => $priority ];
}
$normalized['attach'] = $event;
$normalized['lazy'] = $lazy;
return $normalized;
} | php | {
"resource": ""
} |
q246248 | AbstractStatusEntity.init | validation | private function init($name)
{
if (null === $name) {
$name = $this->default;
}
if (!isset(static::$orderMap[ $name ])) {
throw new \InvalidArgumentException(sprintf(
'Unknown status name "%s" for "%s"',
$name,
static::class
));
}
$this->name = $name;
$this->order = static::$orderMap[ $name ];
} | php | {
"resource": ""
} |
q246249 | ContentCollector.trigger | validation | public function trigger($event, $target = null)
{
if (empty($this->_template) || !is_string($this->_template)) {
throw new \InvalidArgumentException('ContentCollector must have a template-name');
}
$responseCollection = $this->getController()->getEventManager()->trigger($event, $target);
$viewModel = new ViewModel();
$viewModel->setTemplate($this->_template);
foreach ($responseCollection as $i => $response) {
if (is_string($response)) {
$template = $response;
$response = new ViewModel(array('target' => $target));
$response->setTemplate($template);
}
$viewModel->addChild($response, $this->_captureTo . $i);
}
return $viewModel;
} | php | {
"resource": ""
} |
q246250 | TranslatorAwareMessage.setSubject | validation | public function setSubject($subject, $translate = true)
{
if (false !== $translate) {
$translator = $this->getTranslator();
$domain = $this->getTranslatorTextDomain();
if (true === $translate) {
$subject = $translator->translate($subject, $domain);
} else {
$args = func_get_args();
$args[0] = $translator->translate($args[0], $domain);
$subject = call_user_func_array('sprintf', $args);
}
}
return parent::setSubject($subject);
} | php | {
"resource": ""
} |
q246251 | PermissionsAwareTrait.getPermissions | validation | public function getPermissions()
{
if (!$this->permissions) {
$type = property_exists($this, 'permissionsType')
? $this->permissionsType
: str_replace('\\Entity\\', '/', static::class);
$permissions = new Permissions($type);
if (method_exists($this, 'setupPermissions')) {
$this->setupPermissions($permissions);
}
$this->setPermissions($permissions);
}
return $this->permissions;
} | php | {
"resource": ""
} |
q246252 | LogStrategy.getLogger | validation | public function getLogger() : LoggerInterface
{
if (!$this->logger) {
$logger = new class implements LoggerInterface
{
public function emerg($message, $extra = []) : void {}
public function alert($message, $extra = []) : void {}
public function crit($message, $extra = []) : void {}
public function err($message, $extra = []) : void {}
public function warn($message, $extra = []) : void {}
public function notice($message, $extra = []) : void {}
public function info($message, $extra = []) : void {}
public function debug($message, $extra = []) : void {}
};
$this->setLogger($logger);
}
return $this->logger;
} | php | {
"resource": ""
} |
q246253 | LogStrategy.injectLogger | validation | public function injectLogger(bool $flag = null) : bool
{
if (null === $flag) { return $this->injectLogger; }
$this->injectLogger = $flag;
return $flag;
} | php | {
"resource": ""
} |
q246254 | LogStrategy.attach | validation | public function attach(EventManagerInterface $events, $priority = 1) : void
{
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_BOOTSTRAP, [$this, 'logBootstrap'], 1000);
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_FINISH, [$this, 'logFinish'], 1000);
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_JOB, [$this, 'logJobStart'], 1000);
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_JOB, [$this, 'logJobEnd'], -1000);
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_IDLE, [$this, 'injectLoggerInEvent'], 1000);
$this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_STATE, [$this, 'injectLoggerInEvent'], 1000);
} | php | {
"resource": ""
} |
q246255 | LogStrategy.logBootstrap | validation | public function logBootstrap(BootstrapEvent $event) : void
{
$this->getLogger()->info(sprintf(
$this->tmpl['queue'],
'Start',
$event->getQueue()->getName()
));
$this->injectLoggerInObject($event->getWorker());
$this->injectLoggerInEvent($event);
} | php | {
"resource": ""
} |
q246256 | LogStrategy.logFinish | validation | public function logFinish(FinishEvent $event) : void
{
$this->getLogger()->info(sprintf(
$this->tmpl['queue'],
'Stop',
$event->getQueue()->getName()
));
$this->injectLoggerInEvent($event);
} | php | {
"resource": ""
} |
q246257 | LogStrategy.logJobStart | validation | public function logJobStart(ProcessJobEvent $event) : void
{
$queue = $event->getQueue();
$job = $event->getJob();
$logger = $this->getLogger();
$logger->info(sprintf(
$this->tmpl['job'],
$queue->getName(),
'START',
$this->formatJob($job),
''
));
$this->injectLoggerInObject($job);
$this->injectLoggerInEvent($event);
} | php | {
"resource": ""
} |
q246258 | LogStrategy.logJobEnd | validation | public function logJobEnd(ProcessJobEvent $event) : void
{
$result = $event->getResult();
$job = $event->getJob();
$queue = $event->getQueue()->getName();
$logger = $this->getLogger();
switch ($result) {
default:
$logger->info(sprintf(
$this->tmpl['job'],
$queue,
'SUCCESS',
$this->formatJob($job)
));
break;
case ProcessJobEvent::JOB_STATUS_FAILURE_RECOVERABLE:
$logger->warn(sprintf(
$this->tmpl['job'],
$queue,
'RECOVERABLE',
$this->formatJob($job)
));
break;
case ProcessJobEvent::JOB_STATUS_FAILURE:
$logger->err(sprintf(
$this->tmpl['job'],
$queue,
'FAILURE',
$this->formatJob($job)
));
break;
}
} | php | {
"resource": ""
} |
q246259 | FieldsetCustomizationOptions.isEnabled | validation | public function isEnabled($field)
{
return !isset($this->fields[$field]['enabled']) || (bool) $this->fields[$field]['enabled'];
} | php | {
"resource": ""
} |
q246260 | FieldsetCustomizationOptions.getFieldOptions | validation | public function getFieldOptions($field)
{
if (!$this->hasField($field)) {
return [];
}
if (!isset($this->fields[$field]['__options__'])) {
$this->fields[$field]['__options__'] = $this->copyArrayValues(
$this->fields[$field],
[
'attributes',
'options',
'label' => 'options',
'required' => ['key' => ['attributes','*'], 'value' => 'required', 'if' => true],
'type',
]
);
}
return $this->fields[$field]['__options__'];
} | php | {
"resource": ""
} |
q246261 | FieldsetCustomizationOptions.getFieldFlags | validation | public function getFieldFlags($field)
{
if (!$this->hasField($field)) {
return [];
}
if (!isset($this->fields[$field]['__flags__'])) {
$this->fields[$field]['__flags__'] = $this->copyArrayValues(
$this->fields[$field],
[
'flags' => [],
'order' => ['priority'],
'priority'
]
);
}
return $this->fields[$field]['__flags__'];
} | php | {
"resource": ""
} |
q246262 | FieldsetCustomizationOptions.getFieldInputSpecification | validation | public function getFieldInputSpecification($field)
{
if (!$this->hasField($field)) {
return [];
}
if (!isset($this->fields[$field]['__filter__'])) {
$this->fields[$field]['__filter__'] = $this->copyArrayValues(
$this->fields[$field],
[
'input_filter' => [],
'required',
]
);
}
return $this->fields[$field]['__filter__'];
} | php | {
"resource": ""
} |
q246263 | FieldsetCustomizationOptions.copyArrayValues | validation | protected function copyArrayValues(array $source, array $keys)
{
$target = [];
foreach ($keys as $key => $spec) {
if (is_int($key)) {
$key = $spec;
$spec = null;
}
if (!array_key_exists($key, $source)) {
continue;
}
if (null === $spec) {
$target[$key] = $source[$key];
continue;
}
if (is_string($spec)) {
$target[$spec][$key] = $source[$key];
continue;
}
if (isset($spec['if']) && $source[$key] !== $spec['if']) {
continue;
}
if (isset($spec['key'])) {
$targetKeys = is_array($spec['key']) ? $spec['key'] : [$spec['key']];
$value = isset($spec['value']) ? $spec['value'] : $source[$key];
} else {
$targetKeys = $spec;
$value = $source[$key];
}
$tmpTarget =& $target;
foreach ($targetKeys as $targetKey) {
if ('*' == $targetKey) {
$targetKey = $key;
}
if (!isset($tmpTarget[$targetKey])) {
$tmpTarget[$targetKey] = [];
}
$tmpTarget =& $tmpTarget[$targetKey];
}
$tmpTarget = $value;
}
return $target;
} | php | {
"resource": ""
} |
q246264 | TreeSelectStrategy.allowSelectMultipleItems | validation | public function allowSelectMultipleItems()
{
$flagOrCallback = $this->allowSelectMultipleItems;
return is_callable($flagOrCallback) ? (bool) $flagOrCallback() : (bool) $flagOrCallback;
} | php | {
"resource": ""
} |
q246265 | TreeSelectStrategy.findLeaf | validation | private function findLeaf(NodeInterface $leaf, $value)
{
$parts = is_array($value) ? $value : explode($this->shouldUseNames() ? ' | ': '-', $value);
$value = array_shift($parts);
/* @var NodeInterface $item */
foreach ($leaf->getChildren() as $item) {
$compare = $this->shouldUseNames() ? $item->getName() : $item->getValue();
if ($compare == $value) {
if (count($parts)) {
return $this->findLeaf($item, $parts);
}
return $item;
}
}
if ($value && $this->shouldCreateLeafs()) {
$nodeClass = get_class($leaf);
$node = new $nodeClass($value);
$leaf->addChild($node);
if (count($parts)) {
return $this->findLeaf($node, $parts);
}
return $node;
}
return null;
} | php | {
"resource": ""
} |
q246266 | FormFileUpload.renderMarkup | validation | protected function renderMarkup(FileUpload $element)
{
$markup = '
<div class="%s" id="%s-dropzone">
%s
__input__
</div>';
return sprintf(
$markup,
$this->getDropZoneClass($element),
$element->getAttribute('id'),
$this->renderFileList($element)
);
} | php | {
"resource": ""
} |
q246267 | AbstractCustomizableFieldsetFactory.getCustomizationOptions | validation | protected function getCustomizationOptions(ContainerInterface $container, $requestedName, array $options = null)
{
if (!static::OPTIONS_NAME) {
throw new \RuntimeException('The class constants "OPTIONS_NAME" must be non empty.');
}
return $container->get(static::OPTIONS_NAME);
} | php | {
"resource": ""
} |
q246268 | PageManager.getTemplate | validation | public function getTemplate($page)
{
// determine page bundle name.
$bundle = $this->getBundleName(ClassUtils::getRealClass(get_class($page)));
return sprintf('%s:Page:%s.html.twig', $bundle, $page->getTemplateName());
} | php | {
"resource": ""
} |
q246269 | PageManager.decorateClassMetaData | validation | public function decorateClassMetaData(ClassMetadata $c)
{
$parentClassName = $c->getName();
if (isset($this->mappings[$parentClassName])) {
$c->discriminatorMap = array();
$c->discriminatorMap[strtolower(Str::classname($parentClassName))] = $parentClassName;
foreach ($this->mappings[$parentClassName] as $className) {
$bundlePrefix = Str::infix($this->getBundleName($className), '-');
$name = Str::infix(Str::classname(Str::rstrip($className, Str::classname($parentClassName))), '-');
$combinedDiscriminator = sprintf('%s-%s', $bundlePrefix, $name);
$c->discriminatorMap[$combinedDiscriminator] = $className;
$c->subClasses[] = $className;
}
$c->subClasses = array_unique($c->subClasses);
}
} | php | {
"resource": ""
} |
q246270 | PageManager.findForView | validation | public function findForView($id)
{
$type = $this->doctrine->getConnection()->fetchColumn('SELECT type FROM page WHERE id=:id', array('id' => $id));
if (!$type) {
throw new NotFoundHttpException;
}
$types = $this->em->getClassMetadata($this->pageClassName)->discriminatorMap;
$class = $types[$type];
$repos = $this->em->getRepository($class);
if ($repos instanceof ViewablePageRepository) {
$ret = $repos->findForView($id);
} else {
$ret = $repos->find($id);
}
if (!$ret) {
throw new NotFoundHttpException;
}
$this->setLoadedPage($ret);
return $ret;
} | php | {
"resource": ""
} |
q246271 | PageManager.findPageBy | validation | public function findPageBy($repository, $conditions)
{
$ret = $this->em->getRepository($repository)->findOneBy($conditions);
if (!$ret) {
throw new NotFoundHttpException;
}
return $ret;
} | php | {
"resource": ""
} |
q246272 | PageManager.setLoadedPage | validation | public function setLoadedPage($loadedPage)
{
$this->dispatch(Event\PageEvents::PAGE_VIEW, new Event\PageViewEvent($loadedPage));
$this->loadedPage = $loadedPage;
} | php | {
"resource": ""
} |
q246273 | PageManager.getLoadedPage | validation | public function getLoadedPage($default = null)
{
if (!$this->loadedPage) {
if (is_callable($default)) {
$page = call_user_func($default, $this);
if ($page !== null) {
$this->setLoadedPage($page);
}
}
if (!$this->loadedPage) {
throw new NotFoundHttpException("There is no page currently loaded, but it was expected");
}
}
return $this->loadedPage;
} | php | {
"resource": ""
} |
q246274 | FileCopyStrategy.extract | validation | public function extract($value)
{
if (!$value instanceof FileInterface) {
return null;
}
// Store binary data in temporary file.
$tmp = tempnam(sys_get_temp_dir(), 'yk-copy.');
$out = fopen($tmp, 'w');
$in = $value->getResource();
// ensures garbage removal
register_shutdown_function(
function ($filename) {
@unlink($filename);
},
$tmp
);
while (!feof($in)) {
fputs($out, fgets($in, 1024));
}
fclose($in);
fclose($out);
$return = ["file" => $tmp];
foreach (['user', 'name', 'type'] as $key) {
$v = $value->{"get$key"}();
if ($v) {
$return[$key]=$v;
}
}
return $return;
} | php | {
"resource": ""
} |
q246275 | FileCopyStrategy.hydrate | validation | public function hydrate($value)
{
if (!is_array($value)) {
return null;
}
$entity = $this->getTargetEntity();
foreach ($value as $key=>$v) {
$entity->{"set$key"}($v);
}
return $entity;
} | php | {
"resource": ""
} |
q246276 | MailService.setFrom | validation | public function setFrom($email, $name = null)
{
if (is_array($email)) {
$this->from = [$email['email'] => $email['name']];
} else {
$this->from = is_object($email) || null === $name
? $email
: array($email => $name);
}
return $this;
} | php | {
"resource": ""
} |
q246277 | AdminController.indexAction | validation | public function indexAction()
{
/* @var \Core\EventManager\EventManager $events
* @var AdminControllerEvent $event */
$events = $this->adminControllerEvents;
$event = $events->getEvent(AdminControllerEvent::EVENT_DASHBOARD, $this);
$events->trigger($event, $this);
$model = new ViewModel();
$widgets = [];
foreach ($event->getViewModels() as $name => $child) {
$model->addChild($child, $name);
$widgets[] = $name;
}
$model->setVariable('widgets', $widgets);
return $model;
} | php | {
"resource": ""
} |
q246278 | ImageSet.setImages | validation | public function setImages(array $images, PermissionsInterface $permissions = null)
{
$this->clear();
foreach ($images as $prop => $image) {
$this->set($prop, $image, /* check */ false);
}
if ($permissions) {
$this->setPermissions($permissions);
}
return $this;
} | php | {
"resource": ""
} |
q246279 | ImageSet.get | validation | public function get($key, $fallback = true)
{
foreach ($this->getImages() as $image) {
/* @var ImageInterface $image */
if ($key == $image->getKey()) {
return $image;
}
}
return !$fallback || self::ORIGINAL == $key ? null : $this->get(self::ORIGINAL);
} | php | {
"resource": ""
} |
q246280 | ImageSet.set | validation | public function set($key, ImageInterface $image, $check = true)
{
$images = $this->getImages();
if ($check && ($img = $this->get($key))) {
$images->removeElement($img);
}
$image->setBelongsTo($this->id);
$image->setKey($key);
$images->add($image);
return $this;
} | php | {
"resource": ""
} |
q246281 | ImageSet.setPermissions | validation | public function setPermissions(PermissionsInterface $permissions)
{
foreach ($this->getImages() as $file) {
/* @var PermissionsInterface $filePermissions */
/* @var \Core\Entity\FileInterface $file */
$filePermissions = $file->getPermissions();
$filePermissions->clear();
$filePermissions->inherit($permissions);
}
return $this;
} | php | {
"resource": ""
} |
q246282 | Module.onBootstrap | validation | public function onBootstrap(MvcEvent $e)
{
// Register the TimezoneAwareDate type with DoctrineMongoODM
// Use it in Annotations ( @Field(type="tz_date") )
if (!DoctrineType::hasType('tz_date')) {
DoctrineType::addType(
'tz_date',
'\Core\Repository\DoctrineMongoODM\Types\TimezoneAwareDate'
);
}
$sm = $e->getApplication()->getServiceManager();
$translator = $sm->get('translator'); // initialize translator!
\Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
$eventManager = $e->getApplication()->getEventManager();
$sharedManager = $eventManager->getSharedManager();
if (!\Zend\Console\Console::isConsole()) {
(new ErrorHandlerListener())->attach($eventManager);
/* @var \Core\Options\ModuleOptions $options */
$languageRouteListener = new LanguageRouteListener(
$sm->get('Core/Locale'),
$sm->get('Core/Options')
);
$languageRouteListener->attach($eventManager);
$ajaxRenderListener = new AjaxRenderListener();
$ajaxRenderListener->attach($eventManager);
$ajaxRouteListener = $sm->get(AjaxRouteListener::class);
$ajaxRouteListener->attach($eventManager);
$xmlRenderListener = new XmlRenderListener();
$xmlRenderListener->attach($eventManager);
$enforceJsonResponseListener = new EnforceJsonResponseListener();
$enforceJsonResponseListener->attach($eventManager);
$stringListener = new StringListener();
$stringListener->attach($eventManager);
}
$notificationListener = $sm->get('Core/Listener/Notification');
$notificationListener->attachShared($sharedManager);
$notificationAjaxHandler = new NotificationAjaxHandler();
$eventManager->attach(MvcEvent::EVENT_DISPATCH, array($notificationAjaxHandler, 'injectView'), -20);
$notificationListener->attach(NotificationEvent::EVENT_NOTIFICATION_HTML, array($notificationAjaxHandler, 'render'), -20);
$eventManager->attach(
MvcEvent::EVENT_DISPATCH_ERROR,
function ($event) {
if ($event instanceof MvcEvent) {
$application = $event->getApplication();
if ($application::ERROR_EXCEPTION == $event->getError()) {
$ex = $event->getParam('exception');
if (404 == $ex->getCode()) {
$event->setError($application::ERROR_CONTROLLER_NOT_FOUND);
}
}
}
},
500
);
$eventManager->attach(
MvcEvent::EVENT_DISPATCH,
function ($event) use ($eventManager) {
$eventManager->trigger('postDispatch', $event);
},
-150
);
$sm->get('Tracy')->startDebug();
} | php | {
"resource": ""
} |
q246283 | Notification.setListener | validation | public function setListener($listener)
{
$listener->getSharedManager()->attach('*', NotificationEvent::EVENT_NOTIFICATION_HTML, array($this,'createOutput'), 1);
$this->notificationListener = $listener;
} | php | {
"resource": ""
} |
q246284 | Notification.addMessage | validation | public function addMessage($message, $namespace = self::NAMESPACE_INFO)
{
if (!$message instanceof NotificationEntityInterface) {
$messageText = $this->isTranslatorEnabled()
? $this->getTranslator()->translate($message, $this->getTranslatorTextDomain())
: $message;
$message = new NotificationEntity();
$message->setNotification($messageText);
$message->setPriority($this->namespace2priority[$namespace]);
}
$nEvent = new NotificationEvent();
$nEvent->setNotification($message);
$this->notificationListener->trigger(NotificationEvent::EVENT_NOTIFICATION_ADD, $nEvent);
return $this;
} | php | {
"resource": ""
} |
q246285 | LanguageRouteListener.onRoute | validation | public function onRoute(MvcEvent $e)
{
$routeMatch = $e->getRouteMatch();
if (0 !== strpos($routeMatch->getMatchedRouteName(), 'lang')) {
// We do not have a language enabled route here.
// but we need to provide a language to the navigation container
$lang = $this->detectLanguage($e);
$this->setLocale($e, $lang);
return;
}
$language = $routeMatch->getParam('lang', '__NOT_SET__');
if ($this->localeService->isLanguageSupported($language)) {
$this->setLocale($e, $language);
} else {
$e->setError(Application::ERROR_ROUTER_NO_MATCH);
$e->setTarget($this);
$eventManager = $e->getApplication()->getEventManager();
$eventManager->setEventPrototype($e);
$result = $eventManager->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e);
return $result->last();
}
} | php | {
"resource": ""
} |
q246286 | PaginationBuilder.paginator | validation | public function paginator($paginatorName, $defaultParams = [], $as = 'paginator')
{
if (is_string($defaultParams)) {
$as = $defaultParams;
$defaultParams = [];
}
$this->stack['paginator'] = ['as' => $as, $paginatorName, $defaultParams];
return $this;
} | php | {
"resource": ""
} |
q246287 | PaginationBuilder.form | validation | public function form($form, $options = null, $as = 'searchform')
{
if (is_string($options)) {
$as = $options;
$options = null;
}
$this->stack['form'] = ['as' => $as, $form, $options];
return $this;
} | php | {
"resource": ""
} |
q246288 | PaginationBuilder.getResult | validation | public function getResult($paginatorAlias = null, $formAlias = null)
{
if (null === $paginatorAlias) {
$paginatorAlias = isset($this->stack['paginator']['as'])
? $this->stack['paginator']['as']
: 'paginator';
}
if (null === $formAlias) {
$formAlias = isset($this->stack['form']['as']) ? $this->stack['form']['as'] : 'searchform';
}
/* @var \Zend\Mvc\Controller\AbstractController $controller
* @var \Zend\Http\Request $request */
$result = [];
$controller = $this->getController();
$request = $controller->getRequest();
$this->setParameters($request->getQuery());
if (isset($this->stack['params'])) {
$this->callPlugin('paginationParams', $this->stack['params']);
}
if (isset($this->stack['form'])) {
$form = $this->callPlugin('searchform', $this->stack['form']);
if (!$request->isXmlHttpRequest()) {
$result[$formAlias] = $form;
}
}
if (isset($this->stack['paginator'])) {
$result[$paginatorAlias] = $this->callPlugin('paginator', $this->stack['paginator']);
}
return $result;
} | php | {
"resource": ""
} |
q246289 | PaginationBuilder.callPlugin | validation | protected function callPlugin($name, $args)
{
/* @var \Zend\Mvc\Controller\AbstractController $controller */
$controller = $this->getController();
$plugin = $controller->plugin($name);
/* We remove the array entry with the key "as" here.
* because we want to keep it in the stack array */
unset($args['as']);
/* Inject the internal parameters as last argument.
* This is needed to prevent messing with the original query params. */
array_push($args, $this->parameters);
return call_user_func_array($plugin, $args);
} | php | {
"resource": ""
} |
q246290 | AbstractEntity.__isset | validation | public function __isset($property)
{
trigger_error(
sprintf(
'Using isset() with entity properties is deprecated. Use %s::notEmpty("%s") instead.',
get_class($this),
$property
),
E_USER_DEPRECATED
);
return $this->notEmpty($property);
} | php | {
"resource": ""
} |
q246291 | EventManager.trigger | validation | public function trigger($eventName, $target = null, $argv = [])
{
$event = $eventName instanceof EventInterface
? $eventName
: $this->getEvent($eventName, $target, $argv);
return $this->triggerListeners($event);
} | php | {
"resource": ""
} |
q246292 | EventManager.triggerUntil | validation | public function triggerUntil(callable $callback, $eventName, $target = null, $argv = [])
{
$event = $eventName instanceof EventInterface
? $eventName
: $this->getEvent($eventName, $target, $argv);
return $this->triggerListeners($event, $callback);
} | php | {
"resource": ""
} |
q246293 | AjaxEvent.getContentType | validation | public function getContentType()
{
if (!$this->contentType) {
$this->setContentType($this->getParam('contentType') ?: static::TYPE_JSON);
}
return $this->contentType;
} | php | {
"resource": ""
} |
q246294 | AjaxEvent.setResponse | validation | public function setResponse(Response $response)
{
$this->setParam('response', $response);
$this->response = $response;
return $this;
} | php | {
"resource": ""
} |
q246295 | LocalizationSettingsFieldset.init | validation | public function init()
{
$this->setLabel('general settings');
$this->add(
array(
'type' => 'Core\Form\Element\Select',
'name' => 'language',
'options' => array(
'label' => /* @translate */ 'choose your language',
'value_options' => array(
'en' => /* @translate */ 'English',
'fr' => /* @translate */ 'French',
'de' => /* @translate */ 'German',
'it' => /* @translate */ 'Italian',
'po' => /* @translate */ 'Polish',
'ru' => /* @translate */ 'Russian',
'tr' => /* @translate */ 'Turkish',
'es' => /* @translate */ 'Spanish',
),
'description' => /* @translate */ 'defines the languages of this frontend.'
),
)
);
$timezones=array_merge(
\DateTimeZone::listIdentifiers(\DateTimeZone::AFRICA),
\DateTimeZone::listIdentifiers(\DateTimeZone::AMERICA),
\DateTimeZone::listIdentifiers(\DateTimeZone::ASIA),
\DateTimeZone::listIdentifiers(\DateTimeZone::ATLANTIC),
\DateTimeZone::listIdentifiers(\DateTimeZone::AUSTRALIA),
\DateTimeZone::listIdentifiers(\DateTimeZone::EUROPE),
\DateTimeZone::listIdentifiers(\DateTimeZone::INDIAN),
\DateTimeZone::listIdentifiers(\DateTimeZone::PACIFIC)
);
$this->add(
array(
'type' => 'Core\Form\Element\Select',
'name' => 'timezone',
'options' => array(
'label' => /* @translate */ 'choose your timzone',
'value_options' => $timezones,
'description' => /* @translate */ 'defines your local timezone.'
),
)
);
} | php | {
"resource": ""
} |
q246296 | RepositoryAbstractFactory.getEntityClassName | validation | protected function getEntityClassName($name)
{
$repositoryName = str_replace('Repository/', '', $name);
$nameParts = explode('/', $repositoryName);
$namespace = $nameParts[0];
$entity = isset($nameParts[1]) ? $nameParts[1] : substr($namespace, 0, -1);
$class = "\\$namespace\\Entity\\$entity";
return $class;
} | php | {
"resource": ""
} |
q246297 | ListenerAggregateTrait.attachEvents | validation | public function attachEvents(EventManagerInterface $events, array $eventsSpec = null)
{
if (null === $eventsSpec) {
$eventsSpec = $this->eventsProvider();
}
foreach ($eventsSpec as $spec) {
if (!is_array($spec) || 2 > count($spec)) {
throw new \UnexpectedValueException('Event specification must be an array with at least two entries: event name and method name.');
}
$event = $spec[0];
$method = $spec[1];
$priority = isset($spec[2]) ? $spec[2] : 0;
$this->listeners[] = $events->attach($event, [ $this, $method ], $priority);
}
return $this;
} | php | {
"resource": ""
} |
q246298 | LazyControllerFactory.getClassName | validation | private function getClassName($requestedName)
{
$exp = explode('/', $requestedName);
$className = array_shift($exp).'\\Controller\\'.implode('\\', $exp).'Controller';
if (!class_exists($className)) {
throw new ServiceNotCreatedException(
sprintf(
'Can\'t find correct controller class for "%s"',
$requestedName
)
);
}
return $className;
} | php | {
"resource": ""
} |
q246299 | Poser.generate | validation | public function generate($subject, $status, $color, $format)
{
$badge = new Badge($subject, $status, $color, $format);
return $this->getRenderFor($badge->getFormat())->render($badge);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.