_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q250300
Table.addUnique
validation
public function addUnique(string ...$name): self { $key = new Index(...$name); $key->setUnique(); $this->keys[$key->name] = $key; return $this; }
php
{ "resource": "" }
q250301
Table.setPrimaryKey
validation
public function setPrimaryKey(string ...$key): self { $this->primaryKey = new PrimaryKey($this, ...$key); return $this; }
php
{ "resource": "" }
q250302
Table.getTableData
validation
private function getTableData($table): self { if ($table instanceof Table) { return $table; } elseif (is_subclass_of($table, Mapper::class)) { /* @var $mapper Mapper */ $mapper = $this->container->getByType($table); return $mapper->getStructure(); } else { throw new InvalidArgumentException; } }
php
{ "resource": "" }
q250303
Table.getTableSchema
validation
private function getTableSchema(): ?Row { return $this->connection->query(" SELECT [tab.ENGINE], [col.COLLATION_NAME], [col.CHARACTER_SET_NAME] FROM [information_schema.TABLES] tab JOIN [information_schema.COLLATION_CHARACTER_SET_APPLICABILITY] col ON [tab.TABLE_COLLATION] = [col.COLLATION_NAME] WHERE [tab.TABLE_SCHEMA] = %s AND [tab.TABLE_NAME] = %s", $this->database, $this->name)->fetch(); }
php
{ "resource": "" }
q250304
Table.getKeys
validation
private function getKeys(): array { /* @var $result Key[] */ $result = []; $rows = $this->connection->query(" SELECT [INDEX_NAME], [COLUMN_NAME], [INDEX_TYPE], [NON_UNIQUE], [SEQ_IN_INDEX] FROM [information_schema.STATISTICS] WHERE [TABLE_SCHEMA] = %s AND [TABLE_NAME] = %s AND [INDEX_NAME] != %s", $this->database, $this->name, 'PRIMARY'); foreach ($rows as $row) { $name = $row->INDEX_NAME; if (isset($result[$name])) { $obj = $result[$name]; } else { $obj = new Key; } $obj->name = $name; $obj->addColumn($row->SEQ_IN_INDEX, $row->COLUMN_NAME); $obj->type = $row->INDEX_TYPE; $obj->unique = !$row->NON_UNIQUE; $result[$name] = $obj; } return $result; }
php
{ "resource": "" }
q250305
DefaultListenerAggregate.attachShared
validation
public function attachShared(SharedEventManagerInterface $events) { $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_BOOTSTRAP, array($this, 'onMvcBootstrapLast'), -100000); $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_RENDER, array($this, 'onRenderAddPathStacks'), -900); $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_RENDER, array($this, 'onRenderSpecLayout'), -1000); }
php
{ "resource": "" }
q250306
DefaultListenerAggregate.checkMVC
validation
protected function checkMVC() { // check ViewResolver service to match our need. { $viewResolver = $this->sm->get('ViewResolver'); $return = true; if ($viewResolver instanceof ViewResolver\AggregateResolver) { if ($viewResolver->count() == 2) { $defResolvers = array('Zend\View\Resolver\TemplateMapResolver','Zend\View\Resolver\TemplatePathStack'); foreach($viewResolver->getIterator()->toArray() as $i=>$ro) { if ($defResolvers[$i] != get_class($ro)) { $return = false; break; } } } else { $return = false; } } else { $return = false; } $viewTemplatePathStack = $this->sm->get('ViewTemplatePathStack'); if (! $viewTemplatePathStack instanceof ViewResolver\TemplatePathStack) { throw new \Exception('yimaTheme work with PathStack'); } return $return; }
php
{ "resource": "" }
q250307
MessageMapper.persist
validation
public function persist(MessageInterface $message) { if ($message->getMessageId() > 0) { $this->update($message, null, null, new MessageHydrator); } else { $this->insert($message, null, new MessageHydrator); } return $message; }
php
{ "resource": "" }
q250308
UuidForKey.bootUuidForKey
validation
public static function bootUuidForKey() { static::creating(function ($model) { $model->incrementing = false; $model->attributes[$model->getKeyName()] = (string) Str::orderedUuid(); }); }
php
{ "resource": "" }
q250309
Logger.convert_value_to_string
validation
protected function convert_value_to_string( $value ) { if ( $this->is_resource( $value ) ) { $type = get_resource_type( $value ); return "(Resource:$type)"; } if ( is_object( $value ) ) { if ( $value instanceof \Exception || $value instanceof \Throwable ) { return '(' . get_class( $value ) . "#{$value->getCode()}:{$value->getMessage()})"; } elseif ( $value instanceof \DateTime || ( interface_exists( '\DateTimeInterface' ) && $value instanceof \DateTimeInterface ) ) { return $value->format( \DateTime::ATOM ); } elseif ( method_exists( $value, '__toString' ) ) { return (string) $value; } else { $class = get_class( $value ); return "($class)"; } } if ( is_array( $value ) ) { return '(Array)'; } if ( is_scalar( $value ) ) { return $value; } if ( $value === null ) { return '(Null)'; } return '(Invalid)'; }
php
{ "resource": "" }
q250310
Logger.purge
validation
public function purge( $days_older_than = 60, \wpdb $wpdb ) { $days_older_than = absint( $days_older_than ); $tn = $this->table->get_table_name( $wpdb ); $sql = "DELETE FROM {$tn} WHERE time < DATE_SUB(NOW(), INTERVAL $days_older_than DAY)"; $wpdb->query( $sql ); }
php
{ "resource": "" }
q250311
Parser.parseEachPart
validation
protected static function parseEachPart(array $parts, $format) { $lastPartKey = count($parts) - 1; for ($p = 0; $p <= $lastPartKey; $p++) { $parsedPart = static::parse($parts[$p], $format); $numNewParts = count($parsedPart); if ($numNewParts > 1) { array_splice($parts, $p, 1, $parsedPart); $p += $numNewParts; $lastPartKey += $numNewParts - 1; } } // end of parts for loop return $parts; }
php
{ "resource": "" }
q250312
Handler.prepareException
validation
protected function prepareException(Exception $e) { $e = parent::prepareException($e); if($e instanceof PermissionDoesNotExist || $e instanceof AuthorizationException) { $e = new AuthenticationException($e->getMessage()); } return $e; }
php
{ "resource": "" }
q250313
DynamoDbPaginator.runQuery
validation
private function runQuery(array $query, int $limit): Result { $query['Limit'] = $limit + 1; $result = $this->dynamoDbClient->query($query); $result['Items'] = array_slice($result['Items'], 0, $limit); return $result; }
php
{ "resource": "" }
q250314
PermissionsSync.getRoutes
validation
protected function getRoutes() { return collect($this->routes) ->map(function ($route) { return $this->getRouteInformation($route); }) ->reject(function ($item) { return is_null($item); }) ->sortBy('name') ->pluck('name'); }
php
{ "resource": "" }
q250315
PermissionsSync.getRouteInformation
validation
protected function getRouteInformation(Route $route) { return $this->filterRoute([ 'name' => $route->getName(), 'isAuthorized' => $this->isAuthorized($route), ]); }
php
{ "resource": "" }
q250316
RuleCollection.add
validation
public function add($name, Rule $rule) { unset($this->rules[$name]); $this->rules[$name] = $rule; }
php
{ "resource": "" }
q250317
RuleCollection.addTag
validation
public function addTag($name, array $attributes = array()) { foreach ($this->rules as $rule) { $rule->addTag($name, $attributes); } }
php
{ "resource": "" }
q250318
RuleCollection.addCollection
validation
public function addCollection(RuleCollection $collection) { // we need to remove all rules with the same names first because just replacing them // would not place the new rule at the end of the merged array foreach ($collection->all() as $name => $rule) { unset($this->rules[$name]); $this->rules[$name] = $rule; } $this->resources = array_merge($this->resources, $collection->getResources()); }
php
{ "resource": "" }
q250319
RequestParser.parseContextPrefix
validation
private static function parseContextPrefix(Request &$request, $serverVars = array()) { // Since apache 2.3.13 we have now an additional index which provides the context if (isset($serverVars['CONTEXT_PREFIX']) && $serverVars['CONTEXT_PREFIX'] != '') { $request->setContextPrefix( $serverVars['CONTEXT_PREFIX'] . '/' ); } elseif (isset($serverVars['REDIRECT_BASE'])) { // Try to determine the context from redirect base $request->setContextPrefix ( $serverVars['REDIRECT_BASE'] ); } elseif (isset($serverVars['SCRIPT_FILENAME']) && isset($serverVars['SCRIPT_NAME'])) { // Fallback - get context out of script path if (isset($serverVars['HTTP_HOST'])) { $scriptName = preg_replace('/^.+[\\\\\\/]/', '', $serverVars['SCRIPT_FILENAME']); $request->contextPrefix = str_replace($scriptName, '', $serverVars['SCRIPT_NAME']); } } }
php
{ "resource": "" }
q250320
RequestParser.parseUri
validation
private static function parseUri(Request &$request, $uri, $defaultController, $defaultAction) { // All beyond the context prefix is our application request uri $contextUri = $uri; if (null != $request->getContextPrefix() && '/' != $request->getContextPrefix()) { $contextUri = str_replace($request->getContextPrefix(), '', $uri); } // Split parts $parts = array(); if ($contextUri != '') { while (isset($contextUri[0]) && $contextUri[0] == '/') { $contextUri = substr($contextUri, 1); } $parts = explode('/', $contextUri); } // Check if there was a controller requested if (count($parts) > 0) { $request->setController( ucfirst(trim($parts[0])) ); array_shift($parts); if (! $request->getController()) { $request->setController( $defaultController ); } } // Check if there was an action requested if (count($parts) > 0) { $request->setAction( trim($parts[0]) ); array_shift($parts); if (! $request->getAction()) { $request->setAction( $defaultAction ); } } return $parts; }
php
{ "resource": "" }
q250321
RequestParser.parseElement
validation
private static function parseElement(Request &$req, $serverVars, $elementName, $paramName) { if (isset($serverVars[$elementName])) { $req->setParam( $paramName, $serverVars[$elementName] ); } }
php
{ "resource": "" }
q250322
RequestParser.parseParameters
validation
private static function parseParameters(Request &$req, $serverVars) { self::parseElement($req, $serverVars, 'HTTP_ACCEPT', 'Accept'); self::parseElement($req, $serverVars, 'HTTP_ACCEPT_LANGUAGE', 'Accept-Language'); self::parseElement($req, $serverVars, 'HTTP_ACCEPT_ENCODING', 'Accept-Encoding'); self::parseElement($req, $serverVars, 'HTTP_UA_CPU', 'User-Agent-CPU'); self::parseElement($req, $serverVars, 'HTTP_USER_AGENT', 'User-Agent'); self::parseElement($req, $serverVars, 'HTTP_HOST', 'Host'); self::parseElement($req, $serverVars, 'HTTP_CACHE_COTROL', 'Cache-Control'); self::parseElement($req, $serverVars, 'HTTP_CONNECTION', 'Connection'); self::parseElement($req, $serverVars, 'HTTP_X_FORWARDED_FOR', 'X-Forwarded-For'); if (isset($req->params['Accept-Language'])) { $accepted = explode(',', $req->params['Accept-Language']); $req->params['Accept-Language-Best'] = $accepted[0]; foreach ($accepted as $acceptedLang) { $matches = array(); // TODO: Respect the quality field from rfc2616 if (preg_match("/^((?i)[a-z]{2}[-_](?:[a-z]{2}){1,2}(?:_[a-z]{2})?).*/", $acceptedLang, $matches)) { $req->params['Accept-Language-Best'] = $matches[1]; break; } } } }
php
{ "resource": "" }
q250323
RequestParser.parseRemoteHost
validation
private static function parseRemoteHost(Request &$request, $serverVars = array()) { if (isset($serverVars['REMOTE_ADDR'])) { $request->remoteHost = $serverVars['REMOTE_ADDR']; } if (isset($serverVars['HTTP_X_FORWARDED_FOR'])) { $request->remoteHost = $serverVars['HTTP_X_FORWARDED_FOR']; } }
php
{ "resource": "" }
q250324
RequestParser.parseGetPostSessionCookie
validation
private static function parseGetPostSessionCookie(Request &$request) { foreach ($_GET as $name => $value) { $request->params[$name] = $value; } foreach ($_POST as $name => $value) { $request->params[$name] = $value; } foreach ($_COOKIE as $name => $value) { $request->params[$name] = $value; } foreach ($_FILES as $name => $value) { $request->params[$name] = $value; } if (isset($_SESSION)) { foreach ($_SESSION as $name => $value) { $request->params[$name] = $value; } } }
php
{ "resource": "" }
q250325
ContainerAbstract.add
validation
public function add(string $id, $concrete = null, bool $shared = null): DefinitionInterface { // handle special case when the $id is the interface name and the $concrete the real class. // TODO : bout de code à virer si on recherche directement avec le getAlias du definition if (is_string($concrete) && class_exists($concrete)) { $this->alias($concrete, $id); } $concrete = $concrete ?? $id; $shared = $shared ?? $this->defaultToShared; if (! $concrete instanceof DefinitionInterface) { $concrete = new Definition($id, $concrete); } $this->definitions[$id] = $concrete ->setAlias($id) ->setShared($shared); return $concrete; }
php
{ "resource": "" }
q250326
ContainerAbstract.getAlias
validation
public function getAlias(string $abstract): string { if (! isset($this->aliases[$abstract])) { return $abstract; } if ($this->aliases[$abstract] === $abstract) { throw new ContainerException("[{$abstract}] is aliased to itself."); } return $this->getAlias($this->aliases[$abstract]); }
php
{ "resource": "" }
q250327
Aggregate.getName
validation
public function getName() { if (0 === count($this->queue)) { return false; } /** @var $detector ResolverInterface */ foreach ($this->queue as $detector) { $name = $detector->getName(); if (empty($name) && $name !== '0') { // No resource found; try next resolver continue; } // Resource found; return it $this->lastStrategyFound = $detector; return $name; } return false; }
php
{ "resource": "" }
q250328
Aggregate.attach
validation
public function attach(ResolverInterface $detector, $priority = 1) { $this->queue->insert($detector, $priority); return $this; }
php
{ "resource": "" }
q250329
MemoryStream.slurp
validation
public function slurp(): string { $str = ""; while ($this->ready()) { $str .= $this->read($this->count()); } return $str; }
php
{ "resource": "" }
q250330
Form.viewBody
validation
public function viewBody() { // Get sticky values $sticky_values = hypePrototyper()->prototype->getStickyValues($this->action); hypePrototyper()->prototype->clearStickyValues($this->action); // Get validation errors and messages $validation_status = hypePrototyper()->prototype->getValidationStatus($this->action); hypePrototyper()->prototype->clearValidationStatus($this->action); // Prepare fields $i = 0; foreach ($this->fields as $field) { if (!$field instanceof Field) { continue; } if ($field->getInputView() === false) { continue; } $shortname = $field->getShortname(); if (isset($sticky_values[$shortname])) { $field->setStickyValue($sticky_values[$shortname]); } if (isset($validation_status[$shortname])) { $field->setValidation($validation_status[$shortname]['status'], $validation_status[$shortname]['messages']); } $output .= $field->viewInput(array( 'index' => $i, 'entity' => $this->entity, )); $i++; } $submit = elgg_view('prototyper/input/submit', array( 'entity' => $this->entity, 'action' => $this->action, )); $output .= elgg_format_element('div', array( 'class' => 'elgg-foot', ), $submit); return $output; }
php
{ "resource": "" }
q250331
Form.isMultipart
validation
function isMultipart() { foreach ($this->fields as $field) { if (!$field instanceof Field) { continue; } if ($field->getType() == 'file' || $field->getValueType() == 'file' || $field->getDataType()) { return true; } } return false; }
php
{ "resource": "" }
q250332
Menu.normalizeOptions
validation
protected function normalizeOptions(array $options = []) { $options = parent::normalizeOptions($options); if (isset($options['subLiClassLevel0']) && $options['subLiClassLevel0'] !== null) { $options['subLiClassLevel0'] = (string) $options['subLiClassLevel0']; } else { $options['subLiClassLevel0'] = $this->getSubLiClassLevel0(); } return $options; }
php
{ "resource": "" }
q250333
Menu.putPagePartial
validation
public function putPagePartial($page, $partial) { if (null === $partial || is_string($partial) || is_array($partial)) { $this->pagePartials[$page] = $partial; } return $this; }
php
{ "resource": "" }
q250334
Menu.getPagePartial
validation
public function getPagePartial($page) { if (isset($this->pagePartials[$page])) { return $this->pagePartials[$page]; } return null; }
php
{ "resource": "" }
q250335
ActionController.handle
validation
public function handle() { try { if ($this->validate()) { $result = $this->update(); } } catch (\hypeJunction\Exceptions\ActionValidationException $ex) { register_error(elgg_echo('prototyper:validate:error')); forward(REFERER); } catch (\IOException $ex) { register_error(elgg_echo('prototyper:io:error', array($ex->getMessage()))); forward(REFERER); } catch (\Exception $ex) { register_error(elgg_echo('prototyper:handle:error', array($ex->getMessage()))); forward(REFERER); } if ($result) { system_message(elgg_echo('prototyper:action:success')); forward($this->entity->getURL()); } else { register_error(elgg_echo('prototyper:action:error')); forward(REFERER); } }
php
{ "resource": "" }
q250336
ActionController.validate
validation
public function validate() { hypePrototyper()->prototype->saveStickyValues($this->action); $valid = true; foreach ($this->fields as $field) { if (!$field instanceof Field) { continue; } $validation = $field->validate($this->entity); hypePrototyper()->prototype->setFieldValidationStatus($this->action, $field->getShortname(), $validation); if (!$validation->isValid()) { $valid = false; } } if (!$valid) { throw new \hypeJunction\Exceptions\ActionValidationException("Invalid input"); } hypePrototyper()->prototype->clearStickyValues($this->action); return true; }
php
{ "resource": "" }
q250337
ActionController.update
validation
public function update() { hypePrototyper()->prototype->saveStickyValues($this->action); // first handle attributes foreach ($this->fields as $field) { if ($field->getDataType() == 'attribute') { $this->entity = $field->handle($this->entity); } } if (!$this->entity->save()) { return false; } foreach ($this->fields as $field) { if ($field->getDataType() !== 'attribute') { $this->entity = $field->handle($this->entity); } } if (!$this->entity->save()) { return false; } hypePrototyper()->prototype->clearStickyValues($this->action); return $this->entity; }
php
{ "resource": "" }
q250338
Module.onLoadModulesPostAddServices
validation
public function onLoadModulesPostAddServices(ModuleEvent $e) { /** @var $moduleManager \Zend\ModuleManager\ModuleManager */ $moduleManager = $e->getTarget(); // $sharedEvents = $moduleManager->getEventManager()->getSharedManager(); /** @var $sm ServiceManager */ $sm = $moduleManager->getEvent()->getParam('ServiceManager'); $sm->setInvokableClass('yimaTheme.ThemeObject', 'yimaTheme\Theme\Theme', false); }
php
{ "resource": "" }
q250339
Module.initThemeManager
validation
public function initThemeManager(ModuleEvent $e) { /** @var $moduleManager \Zend\ModuleManager\ModuleManager */ $moduleManager = $e->getTarget(); // $sharedEvents = $moduleManager->getEventManager()->getSharedManager(); $sm = $moduleManager->getEvent()->getParam('ServiceManager'); $themManager = $sm->get('yimaTheme.Manager'); if (!$themManager instanceof ManagerInterface) { throw new \Exception(sprintf( 'yimaTheme theme manager most instance of "ManagerInterface" but "%s" given.' , get_class($themManager) )); } $themManager->init(); }
php
{ "resource": "" }
q250340
ServerSocket.serve
validation
public function serve(ServiceCallback $callback) { $this->bind(); $this->listen(); $runOn = true; while ($runOn) { $clientHandle = @socket_accept($this->handle); if (! is_resource($clientHandle)) { $code = socket_last_error($this->handle); throw new SocketException(socket_strerror($code), array(), $code); } $address = null; $port = 0; if (! @socket_getpeername($clientHandle, $address, $port)) { $code = socket_last_error($clientHandle); throw new SocketException(socket_strerror($code), array(), $code); } $client = new ClientSocket(new Endpoint($address, $port), $clientHandle); $runOn = boolval($callback->callback($client)); } }
php
{ "resource": "" }
q250341
ServerSocket.bind
validation
private function bind() { if (! @socket_bind($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { $code = socket_last_error($this->handle); throw new SocketException(socket_strerror($code), array(), $code); } }
php
{ "resource": "" }
q250342
ServerSocket.listen
validation
private function listen() { if (! @socket_listen($this->handle, 5)) { $code = socket_last_error($this->handle); throw new SocketException(socket_strerror($code), array(), $code); } }
php
{ "resource": "" }
q250343
LogQuery.build_sql
validation
protected function build_sql() { $builder = new Builder(); $select = $this->parse_select(); $from = new From( $this->table->get_table_name( $GLOBALS['wpdb'] ), 'q' ); $where = new Where( 1, true, 1 ); if ( ( $message = $this->parse_message() ) !== null ) { $where->qAnd( $message ); } if ( ( $level = $this->parse_level() ) !== null ) { $where->qAnd( $level ); } if ( ( $user = $this->parse_user() ) !== null ) { $where->qAnd( $user ); } if ( ( $group = $this->parse_group() ) !== null ) { $where->qAnd( $group ); } if ( ( $time = $this->parse_time() ) !== null ) { $where->qAnd( $time ); } $order = $this->parse_order(); $limit = $this->parse_pagination(); $builder->append( $select )->append( $from ); $builder->append( $where ); $builder->append( $order ); if ( $limit !== null ) { $builder->append( $limit ); } return $builder->build(); }
php
{ "resource": "" }
q250344
LogQuery.parse_message
validation
protected function parse_message() { if ( empty( $this->args['message'] ) ) { return null; } $like = esc_sql( $this->args['message'] ); return new Where( 'message', 'LIKE', "%{$like}%" ); }
php
{ "resource": "" }
q250345
LogQuery.parse_user
validation
protected function parse_user() { if ( ! empty( $this->args['user'] ) ) { $this->args['user__in'] = array( $this->args['user'] ); } return $this->parse_in_or_not_in_query( 'user', $this->args['user__in'], $this->args['user__not_in'] ); }
php
{ "resource": "" }
q250346
LogQuery.parse_time
validation
protected function parse_time() { if ( ! empty( $this->args['time'] ) ) { $date_query = new \WP_Date_Query( $this->args['time'], 'q.time' ); return new Where_Date( $date_query ); } else { return null; } }
php
{ "resource": "" }
q250347
Locator.getPreparedThemeObject
validation
public function getPreparedThemeObject() { $name = $this->attainThemeName(); $path = $this->attainPathName(); $return = false; if ($name && $path) { // we are attained theme $return = $this->getThemeObject(); $return->setName($name); $return->setThemesPath($path); } return $return; }
php
{ "resource": "" }
q250348
Locator.getMvcLayout
validation
public function getMvcLayout(MvcEvent $e) { try { $resolver = $this->getResolverObject('mvclayout_resolver_adapter', array('event_mvc' => $e)); } catch (\Exception $e) { throw $e; } $layout = $resolver->getName(); if (empty($layout) && ! ($layout === '0') ) { return false; } return $layout; }
php
{ "resource": "" }
q250349
Locator.attainThemeName
validation
protected function attainThemeName() { $themeName = $this->getResolverObject('resolver_adapter_service') ->getName(); return (empty($themeName) && ! ($themeName === '0')) ? false : $themeName; }
php
{ "resource": "" }
q250350
Locator.getResolverObject
validation
public function getResolverObject($state = null, array $options = array()) { if ($state == null && isset($this->resolverObject['last_resolver'])) { // latest invoked resolver return $this->resolverObject['last_resolver']; } if ($state != 'resolver_adapter_service' && $state != 'mvclayout_resolver_adapter') throw new \Exception('Invalid state name provided.'); // create resolver state object from config $config = $this->getConfig(); if (isset($config['theme_locator'])) $config = $config['theme_locator']; else $config = array(); if (!isset($config[$state])) throw new \Exception("Theme Resolver Service not present in config[$state]."); $config = $config[$state]; // is string, 'resolver_adapter' => 'resolver\service' if (is_string($config)) { $config = array( "{$config}" => 1 ); } if (isset($this->resolverObject[$state])) { $resolver = $this->resolverObject[$state]; $this->resolverObject['last_resolver'] = $resolver; return $resolver; } else $resolver = new Resolvers\Aggregate(); foreach ($config as $service => $priority) { if ($this->getServiceLocator()->has($service)) { $service = $this->getServiceLocator()->get($service); } else { if (!class_exists($service)) throw new \Exception("Resolver '$service' not found for yimaTheme as Service either Class."); $service = new $service(); } if ($service instanceof Resolvers\LocatorResolverAwareInterface) { // inject themeLocator to access config and other things by resolver $service->setThemeLocator($this); } if ($service instanceof Resolvers\ConfigResolverAwareInterface) { // set yimaTheme config for resolver $service->setConfig($this->getConfig()); } if (isset($options['event_mvc'])) if ($service instanceof Resolvers\MvcResolverAwareInterface) $service->setMvcEvent($options['event_mvc']); $resolver->attach($service, $priority); } $this->resolverObject[$state] = $resolver; $this->resolverObject['last_resolver'] = $resolver; return $resolver; }
php
{ "resource": "" }
q250351
Locator.attainPathName
validation
protected function attainPathName() { $path = false; // get default themes path by config { $config = $this->getConfig(); if (isset($config['theme_locator']['themes_default_path'])) { $path = $config['theme_locator']['themes_default_path']; } // ... } // get theme specify path, // use case in modules that present a specify theme inside, like admin panel. $themeName = $this->attainThemeName(); if (isset($config['themes']) && is_array($config['themes']) && isset($config['themes'][$themeName])) { if (array_key_exists('dir_path',$config['themes'][$themeName])) { $path = $config['themes'][$themeName]['dir_path']; } } return $path; }
php
{ "resource": "" }
q250352
Locator.getConfig
validation
protected function getConfig() { // get default manager config used by default theme locator $config = $this->getServiceLocator()->get('config'); if (isset($config['yima-theme']) && is_array($config['yima-theme'])) { $config = $config['yima-theme']; } else { $config = array(); } return $config; }
php
{ "resource": "" }
q250353
Visit.setVisitTime
validation
public function setVisitTime($visitTime) { if ($visitTime instanceof \DateTime) { $this->visitTime = $visitTime; } else { $this->visitTime = new \DateTime($visitTime); } return $this; }
php
{ "resource": "" }
q250354
Application.setUp
validation
public function setUp() { $this->controllers = array(); $this->views = array(); $this->viewControls = array(); $this->setDefaults(); $this->init(); $this->setLogger(new NullLogger()); return $this; }
php
{ "resource": "" }
q250355
Application.init
validation
public function init() { $this->registerController(\Nkey\Caribu\Mvc\Controller\ErrorController::class); $this->registerView(\Nkey\Caribu\Mvc\View\DefaultView::class); }
php
{ "resource": "" }
q250356
Application.setDefaults
validation
public function setDefaults($defaultController = 'Index', $defaultAction = 'index') { $this->defaultController = $defaultController; $this->defaultAction = $defaultAction; return $this; }
php
{ "resource": "" }
q250357
Application.registerView
validation
public function registerView($view, $order = null, $applicationName = 'default') { if (! class_exists($view)) { throw new ViewException("No such view class {view} found", array( 'view' => $view )); } $v = new $view(); if (! $v instanceof View) { throw new ViewException("View {view} is not in application scope", array( 'view' => $view )); } $viewOrder = $v->getOrder(); if (null !== $order) { $viewOrder = intval($order); } $settings = $v->getViewSettings(); $this->views[$applicationName][$viewOrder][$settings->getViewSimpleName()] = $settings; return $this; }
php
{ "resource": "" }
q250358
Application.unregisterView
validation
public function unregisterView($view, $order, $applicationName = 'default') { if (isset($this->views[$applicationName][$order][$view])) { unset($this->views[$applicationName][$order][$view]); } return $this; }
php
{ "resource": "" }
q250359
Application.getViewBestMatch
validation
private function getViewBestMatch(Request $request, $applicationName) { $best = null; if (count($this->views[$applicationName]) > 0) { foreach ($this->views[$applicationName] as $orderLevel => $views) { foreach ($views as $view) { assert($view instanceof View); if ($view->matchBoth($request->getController(), $request->getAction())) { $best[$orderLevel] = $view; continue 2; } } } } if (null == $best) { throw new ViewException("No view found for request"); } if (count($best) > 1) { krsort($best); } return reset($best); }
php
{ "resource": "" }
q250360
Application.registerController
validation
public function registerController($controller, $applicationName = 'default') { if ( !$controller instanceof \Nkey\Caribu\Mvc\Controller\AbstractController ) { if (! class_exists($controller)) { throw new ControllerException("No such controller class {controller} found", array( 'controller' => $controller )); } $c = new $controller(); if (! ($c instanceof AbstractController)) { throw new ControllerException("Controller {controller} is not in application scope", array( 'controller' => $controller )); } } else { $c = $controller; } $settings = $c->getControllerSettings(); $this->controllers[$applicationName][$settings->getControllerSimpleName()] = $settings; return $this; }
php
{ "resource": "" }
q250361
Application.registerRouter
validation
public function registerRouter(AbstractRouter $router) { $this->router = $router; $this->router->setApplication($this); return $this; }
php
{ "resource": "" }
q250362
HttpClientTrait.retrieveHeaders
validation
public function retrieveHeaders(): array { $this->setHeader('Connection', 'close'); $this->setHeader('Accept', ''); $this->setHeader('Accept-Language', ''); $this->setHeader('User-Agent', ''); $savedProto = $this->protocol; $this->protocol = 'HTTP/1.0'; $this->request('HEAD'); $this->protocol = $savedProto; return $this->getHeaders(); }
php
{ "resource": "" }
q250363
HttpClientTrait.prepareRequest
validation
private function prepareRequest($requestType): MemoryStream { $ms = new MemoryStream(); // First send the request type $ms->interpolate("{rqtype} {path}{query} {proto}\r\n", array( 'rqtype' => $requestType, 'path' => $this->path, 'proto' => $this->protocol, 'query' => (strlen($this->queryString) ? '?' . $this->queryString : '') )); // Add the host part $ms->interpolate("Host: {host}\r\n", array( 'host' => $this->getEndpoint() ->getAddress() )); $this->adjustHeaders($requestType); // Add all existing headers foreach ($this->getHeaders() as $headerName => $headerValue) { if (isset($headerValue) && strlen($headerValue) > 0) { $ms->interpolate("{headerName}: {headerValue}\r\n", array( 'headerName' => $headerName, 'headerValue' => $headerValue )); } } $ms->write("\r\n"); return $ms; }
php
{ "resource": "" }
q250364
HttpClientTrait.retrieveAndParseResponse
validation
private function retrieveAndParseResponse($requestType) { $this->payload = new MemoryStream(); $this->headers = array(); $delimiterFound = false; $tmp = ""; $numBytes = 1; $start = time(); while (true) { if (! $this->checkConnection($start)) { continue; } $c = $this->read($numBytes); if ($c == null) { break; } $start = time(); // we have readen something => adjust timeout start point $tmp .= $c; if (! $delimiterFound) { $this->handleHeader($delimiterFound, $numBytes, $tmp); } if ($delimiterFound) { if ($requestType == 'HEAD') { // Header readen, in type HEAD it is now time to leave break; } // delimiter already found, append to payload $this->payload->write($tmp); $tmp = ""; if ($this->checkContentLengthExceeded()) { break; } } } $size = $this->payload->count(); if ($size == 0) { return; } // Set pointer to start $this->payload->reset(); $mayCompressed = $this->payload->read($size); switch ($this->getContentEncoding()) { case 'gzip': $uncompressed = gzdecode(strstr($mayCompressed, "\x1f\x8b")); $this->payload->flush(); $this->payload->write($uncompressed); break; case 'deflate': $uncompressed = gzuncompress($mayCompressed); $this->payload->flush(); $this->payload->write($uncompressed); break; default: // nothing break; } $this->payload->reset(); }
php
{ "resource": "" }
q250365
HttpClientTrait.appendPayloadToRequest
validation
private function appendPayloadToRequest(MemoryStream $ms): MemoryStream { $this->payload->reset(); while ($this->payload->ready()) { $ms->write($this->payload->read(1024)); } $ms->reset(); return $ms; }
php
{ "resource": "" }
q250366
HttpClientTrait.handleHeader
validation
private function handleHeader(&$delimiterFound, &$numBytes, &$tmp) { if ($tmp == "\r\n") { $numBytes = $this->adjustNumbytes($numBytes); $delimiterFound = true; $tmp = ""; return; } if (substr($tmp, - 2, 2) == "\r\n") { $this->addParsedHeader($tmp); $tmp = ""; } }
php
{ "resource": "" }
q250367
HttpClientTrait.requestImpl
validation
private function requestImpl(string $requestType) { if ($requestType == 'HEAD') { $this->setTimeout(1); // Don't wait too long on simple head } $ms = $this->prepareRequest($requestType); $ms = $this->appendPayloadToRequest($ms); if (! $this->isConnected()) { $this->connect(); } while ($ms->ready()) { $this->write($ms->read(1024)); } $this->retrieveAndParseResponse($requestType); if ($this->getHeader('Connection') == 'close') { $this->disconnect(); } }
php
{ "resource": "" }
q250368
HttpClientTrait.checkConnection
validation
private function checkConnection($start): bool { if (! $this->ready()) { if (time() - $start > $this->timeout) { $this->disconnect(); throw new HttpException("Connection timed out!"); } return false; } return true; }
php
{ "resource": "" }
q250369
HttpClientTrait.checkContentLengthExceeded
validation
private function checkContentLengthExceeded(): bool { if (isset($this->headers['Content-Length'])) { if ($this->payload->count() >= $this->headers['Content-Length']) { return true; } } return false; }
php
{ "resource": "" }
q250370
StandardOutputStream.setInterceptor
validation
public function setInterceptor(StreamInterceptor $interceptor) { $this->interceptor = $interceptor; stream_filter_append($this->stdout, $interceptor->getFilterName()); }
php
{ "resource": "" }
q250371
SymfonyAction.create
validation
public static function create($name, SymfonyRoute $route, $method, $description = '') { return new static($name, $route, $method, $description); }
php
{ "resource": "" }
q250372
YamlFileLoader.load
validation
public function load($file, $type = null) { $path = $this->locator->locate($file); if (!stream_is_local($path)) { throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path)); } if (!file_exists($path)) { throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path)); } if (null === $this->yamlParser) { $this->yamlParser = new YamlParser(); } $config = $this->yamlParser->parse(file_get_contents($path)); $collection = new RuleCollection(); $collection->addResource(new FileResource($path)); // empty file if (null === $config) { return $collection; } // not an array if (!is_array($config)) { throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path)); } foreach ($config as $name => $subConfig) { $this->validate($subConfig, $name, $path); if (isset($subConfig['resource'])) { $this->parseImport($collection, $subConfig, $path, $file); } else { $this->parseRule($collection, $name, $subConfig, $path); } } return $collection; }
php
{ "resource": "" }
q250373
YamlFileLoader.validate
validation
protected function validate($config, $name, $path) { if (!is_array($config)) { throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path)); } if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) { throw new \InvalidArgumentException(sprintf( 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys) )); } if (isset($config['resource']) && isset($config['expression'])) { throw new \InvalidArgumentException(sprintf( 'The business rule file "%s" must not specify both the "resource" key and the "expression" key for "%s". Choose between an import and a rule definition.', $path, $name )); } if (!isset($config['resource']) && isset($config['type'])) { throw new \InvalidArgumentException(sprintf( 'The "type" key for the rule definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', $name, $path )); } if (!isset($config['resource']) && !isset($config['expression'])) { throw new \InvalidArgumentException(sprintf( 'You must define an "expression" for the rule "%s" in file "%s".', $name, $path )); } if (isset($config['tags']) && !is_array($config['tags'])) { throw new \InvalidArgumentException(sprintf( 'The "tags" key for the rule definition "%s" in "%s" contains unsupported data. Each tag defined must be an array with at least the "name" element set to a string.', $name, $path )); } elseif (isset($config['tags'])) { foreach ($config['tags'] as $tag) { if (!isset($tag['name'])) { throw new \InvalidArgumentException(sprintf( 'The "tags" key for the rule definition "%s" in "%s" contains unsupported data. Each tag defined must be an array with at least the "name" element set to a string.', $name, $path )); } } } }
php
{ "resource": "" }
q250374
AbstractRouter.route
validation
public function route(string $name, Request $request) { $parts = \explode('/', $request->getOrigin()); $found = false; for($i = 0; $i < count($parts); $i++) { if($parts[$i] === $name && isset($parts[$i+1])) { $action = $parts[$i+1]; if(strpos($action, "?")) { $action = strstr($action, "?", true); } $request->setAction($action); $found = true; } } if(!$found) { $request->setAction("index"); } $controller = $this->getRoute($name); $request->setController($controller->getControllerSimpleName()); return $controller; }
php
{ "resource": "" }
q250375
Topic.setLastPost
validation
public function setLastPost($lastPost) { if ($lastPost == 0) { $this->_lastPost = ""; } elseif ($lastPost !== "" and $lastPost !== "NULL" and $lastPost !== null) { if ($lastPost instanceof DateTime) { $this->_lastPost = $lastPost; } else { $this->_lastPost = new DateTime($lastPost); } } return $this; }
php
{ "resource": "" }
q250376
UrlParser.parseUrl
validation
public static function parseUrl($url): Url { $parts = parse_url($url); if (false === $parts || false === Arrays::hasElement($parts, 'host') || false === Arrays::hasElement($parts, 'scheme')) { throw new InvalidUrlException('The URL {url} does not contain necessary parts', array('url' => $url)); } $address = $parts['host']; $scheme = $parts['scheme']; $query = (isset($parts['query']) ? $parts['query'] : ''); $port = 0; $path = "/"; if (isset($parts['port'])) { $port = intval($parts['port']); } if ($port == 0) { $port = self::getPortByScheme($scheme); } if (isset($parts['path'])) { $path = $parts['path']; } return new Url($address, $port, $path, $scheme, $query); }
php
{ "resource": "" }
q250377
Rule.clearTag
validation
public function clearTag($name) { if (isset($this->tags[$name])) { unset($this->tags[$name]); } return $this; }
php
{ "resource": "" }
q250378
ReflectionResolver.call
validation
public function call(callable $callable, array $args = []) { $args = $this->resolveArguments($args); $reflection = $this->reflectCallable($callable); return call_user_func_array( $callable, $this->getParameters($reflection, $args) ); }
php
{ "resource": "" }
q250379
Formatter.formatCamelCaseWithAcronyms
validation
public static function formatCamelCaseWithAcronyms(array $parts) { $camelCase = array_map(function($p) { return static::ucfirstAndLowerNonAcronym($p); }, $parts); if (static::isAcronym($camelCase[0])) { return implode('', $camelCase); } return lcfirst(implode('', $camelCase)); }
php
{ "resource": "" }
q250380
Request.parse
validation
public static function parse($uri, $serverVars = array(), $defaultController = 'Index', $defaultAction = 'index') { $req = new self($defaultController, $defaultAction); $req->origin = $uri; self::parseRemoteHost($req, $serverVars); self::parseGetPostSessionCookie($req); // Save the request parameters for later usage and rewrite the uri $savedRequestParams = array(); if (strpos($uri, '?')) { parse_str(substr($uri, strpos($uri, '?') + 1), $savedRequestParams); $uri = substr($uri, 0, strpos($uri, '?')); } self::parseContextPrefix($req, $serverVars); $parts = self::parseUri($req, $uri, $defaultController, $defaultAction); // Walk over all parameters and put them into container $numParts = count($parts); for ($i = 0; $i < $numParts; $i = $i + 2) { $paramName = trim($parts[$i]); $paramValue = isset($parts[$i + 1]) ? trim($parts[$i + 1]) : ''; if ($paramName && $paramValue) { $req->params[$paramName] = $paramValue; } } $req->params = array_merge($req->params, $savedRequestParams); self::parseParameters($req, $serverVars); // Et'voila return $req; }
php
{ "resource": "" }
q250381
Request.parseFromServerRequest
validation
public static function parseFromServerRequest($serverVars, $defaultController = 'Index', $defaultAction = 'index') { if (! isset($serverVars['REQUEST_URI'])) { throw new InvalidUrlException("No such uri provided"); } return self::parse($serverVars['REQUEST_URI'], $serverVars, $defaultController, $defaultAction); }
php
{ "resource": "" }
q250382
Request.getParam
validation
public function getParam($name, $typeOf = 'string') { $result = $this->hasParam($name) ? $this->params[$name] : null; switch ($typeOf) { case 'bool': case 'boolean': $result = function_exists('boolval') ? boolval($result) : (bool) $result; break; case 'double': case 'float': $result = doubleval($result); break; case 'int': $result = intval($result); break; case 'string': default: $result = htmlentities(strval($result)); break; } return $result; }
php
{ "resource": "" }
q250383
ParamsTrait.getParams
validation
public function getParams() { // initialize the array for the params $params = array(); // prepare the params, e. g. explode them into an array if ($paramsAvailable = reset($this->params)) { foreach (array_keys($paramsAvailable) as $paramKey) { $params[$paramKey] = $this->getParam($paramKey); } } // return the params return $params; }
php
{ "resource": "" }
q250384
ParamsTrait.getParam
validation
public function getParam($name, $defaultValue = null) { // load the params $params = reset($this->params); // query whether or not, the param with the passed name is set if (is_array($params) && isset($params[$name])) { // load the value from the array $value = $params[$name]; // query whether or not, the value contains a comma => if yes, we explode it into an array if (is_string($value) && stripos($value, $delimiter = $this->getParamDelimiter())) { $value = explode($delimiter, $value); } // return the found value return $value; } // if not, query we query if a default value has been passed if ($defaultValue != null) { return $defaultValue; } // throw an exception if neither the param exists or a default value has been passed throw new \Exception(sprintf('Requested param %s not available', $name)); }
php
{ "resource": "" }
q250385
RandomString.generate
validation
public static function generate($length = 8, $allowed = RandomString::ASCII, $repeatable = true): string { $allowedChars = array(); $currentLocale = setlocale(LC_ALL, "0"); if ($allowed == RandomString::ASCII) { setlocale(LC_ALL, "C"); } for ($i = 32; $i < 256; $i ++) { if (($allowed == RandomString::ASCII && ! ctype_alnum(chr($i))) || (! ctype_print(chr($i)))) { continue; } $allowedChars[] = $i; } self::resetLocaleTo($currentLocale); $used = array(); $string = ""; $i = $length; while ($i > 0) { $index = mt_rand(0, count($allowedChars) - 1); if (! $repeatable && in_array($index, $used)) { continue; } $string .= chr($allowedChars[$index]); $used[] = $i; $i --; } return $string; }
php
{ "resource": "" }
q250386
RandomString.resetLocaleTo
validation
private static function resetLocaleTo($localeSaved) { $localeData = explode(';', $localeSaved); foreach ($localeData as $identifier) { if (! strchr($identifier, '=')) { continue; } $type = $value = null; sscanf($identifier, "%s=%s", $type, $value); switch ($type) { case 'LC_ALL': setlocale(LC_ALL, $value); break; case 'LC_COLLATE': setlocale(LC_COLLATE, $value); break; case 'LC_CTYPE': setlocale(LC_CTYPE, $value); break; case 'LC_MONETARY': setlocale(LC_MONETARY, $value); break; case 'LC_NUMERIC': setlocale(LC_NUMERIC, $value); break; case 'LC_TIME': setlocale(LC_TIME, $value); break; case 'LC_MESSAGES': setlocale(LC_MESSAGES, $value); break; default: ; break; } } }
php
{ "resource": "" }
q250387
Session.get
validation
public function get($key) { if (! isset($this->sessionContainer[$key])) { return null; } return $this->sessionContainer[$key]; }
php
{ "resource": "" }
q250388
Socket.open
validation
private function open() { $this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if (! is_resource($this->handle)) { $code = socket_last_error(); throw new SocketException(socket_strerror($code), array(), $code); } }
php
{ "resource": "" }
q250389
UserNotificationController.markAsRead
validation
public function markAsRead($uid) { if(!$object = $this->model->find($uid)) { abort(404); } $this->authorize('update', $object); $object->markAsRead(); \Cache::tags('response')->flush(); return $this->successJsonResponse(); }
php
{ "resource": "" }
q250390
UserNotificationController.markAsUnread
validation
public function markAsUnread($uid) { if(!$object = $this->model->find($uid)) { abort(404); } $this->authorize('update', $object); if (!is_null($object->read_at)) { $object->forceFill(['read_at' => null])->save(); } \Cache::tags('response')->flush(); return $this->successJsonResponse(); }
php
{ "resource": "" }
q250391
UserMapper.fetchAll
validation
public function fetchAll($columns = null, \Closure $Closure = null) { $select = $this->getSelect(); if ($columns) { $select->columns($columns); } if ($Closure) { $Closure($select); } return $this->select($select); }
php
{ "resource": "" }
q250392
UserMapper.getSelectOptions
validation
public function getSelectOptions() { $filter = new UnderscoreToCamelCase(); $funcName = "get" . ucfirst($filter->filter($this->getUserColumn())); $resultSet = $this->fetchAll(array('user_id', $this->getUserColumn()), function (Select $select) { $select->where->notEqualTo('user_id', $this->getCurrentUser()->getId()); }); $options = array(); foreach ($resultSet as $user) { $options[$user->getId()] = $user->$funcName(); } return $options; }
php
{ "resource": "" }
q250393
Profile.view
validation
public function view($vars = array()) { $output = ''; $vars['entity'] = $this->entity; foreach ($this->fields as $field) { if (!$field instanceof Field) { continue; } if ($field->getOutputView() === false) { continue; } if ($field->getType() == 'hidden' || $field->getValueType() == 'hidden') { continue; } if ($field->isHiddenOnProfile()) { continue; } $field_view = $field->viewOutput($vars); if ($field_view) { $output .= elgg_format_element('div', array( 'class' => 'prototyper-output', ), $field_view); } } return $output; }
php
{ "resource": "" }
q250394
Url.getUrlString
validation
public function getUrlString(): string { $query = ""; if (strlen($this->queryString) > 0) { $query = sprintf("?%s", $this->queryString); } if (($this->scheme == 'http' && $this->getPort() == 80) || ($this->scheme == 'ftp' && $this->getPort() == 21) || ($this->scheme == 'https' && $this->getPort() == 443)) { return sprintf("%s://%s%s%s", $this->scheme, $this->getAddress(), $this->path, $query); } return sprintf("%s://%s:%d%s%s", $this->scheme, $this->getAddress(), $this->getPort(), $this->path, $query); }
php
{ "resource": "" }
q250395
AbstractController.parseParameters
validation
private function parseParameters(\ReflectionMethod $action) { $params = $action->getParameters(); if (count($params) < 1) { return false; } $param = $params[0]; assert($param instanceof \ReflectionParameter); if (! ($class = $param->getClass()) || $class->getName() != 'Nkey\Caribu\Mvc\Controller\Request') { return false; } return true; }
php
{ "resource": "" }
q250396
AbstractController.parseAnnotations
validation
private function parseAnnotations(\ReflectionMethod $action) { if ($action->isConstructor() || $action->isDestructor() || $action->isStatic() || $action->isFinal()) { return; } $rfMethod = new \ReflectionMethod($this, $action->name); $anno = $rfMethod->getDocComment(); if ($anno && preg_match('#@webMethod#', $anno)) { $this->actions[] = $action->name; return; } if (! $this->parseParameters($action)) { return; } $this->actions[] = $action->name; }
php
{ "resource": "" }
q250397
AbstractController.getControllerSettings
validation
final public function getControllerSettings() { $rf = new \ReflectionClass($this); $this->response = new Response(); $this->controllerClass = $rf->getShortName(); $this->controllerName = ucfirst(str_replace('Controller', '', $this->controllerClass)); $this->response->setTitle($this->controllerName); $actions = $rf->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($actions as $action) { $this->parseAnnotations($action); } return $this; }
php
{ "resource": "" }
q250398
AbstractController.call
validation
final public function call($action, Request $request, View $view) { $this->request = $request; ob_start(); $rf = new \ReflectionMethod($this, $action); $anno = $rf->getDocComment(); $matches = array(); if (preg_match('#@responseType ([\w\/]+)#', $anno, $matches)) { $this->response->setType($matches[1]); } if (preg_match('#@title ([^\\n]+)#', $anno, $matches)) { $this->response->setTitle($matches[1]); } $rf->invoke($this, $this->request); $this->response->appendBody(ob_get_clean()); $view->render($this->response, $request, $this->viewParams); $this->addControls($this->response, $request, $view); return $this->response; }
php
{ "resource": "" }
q250399
AbstractController.addControls
validation
protected function addControls(Response &$response, Request $request, View $view) { $matches = array(); while (preg_match("/\{(\w+)=(\w+)\}/", $response->getBody(), $matches)) { $controlIdentifier = $matches[1]; $controlName = $matches[2]; $currentBody = $response->getBody(); if (! isset($this->viewParams[$controlIdentifier][$controlName]) || ! $view->hasControl($controlIdentifier)) { $response->setBody(str_replace($matches[0], '', $currentBody)); continue; } if ($this->viewParams[$controlIdentifier][$controlName] instanceof Control) { $repl = $this->viewParams[$controlIdentifier][$controlName]->render($request); } else { $control = $view->createControl($controlIdentifier); $repl = $control->render($request, $this->viewParams[$controlIdentifier][$controlName]); } $response->setBody(str_replace($matches[0], $repl, $currentBody)); } }
php
{ "resource": "" }