_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q6600
Model.validates
train
public function validates($options = []) { $this->sync(); $exists = $this->exists(); $defaults = [ 'events' => $exists ? 'update' : 'create', 'required' => $exists ? false : true, 'entity' => $this, 'embed' => true ]; $op...
php
{ "resource": "" }
q6601
Model._validates
train
protected function _validates($options) { $defaults = ['embed' => true]; $options += $defaults; if ($options['embed'] === true) { $options['embed'] = $this->hierarchy(); } $schema = $this->schema(); $tree = $schema->treeify($options['embed']); $s...
php
{ "resource": "" }
q6602
Model.invalidate
train
public function invalidate($field, $errors = []) { $schema = $this->schema(); if (func_num_args() === 1) { foreach ($field as $key => $value) { if ($schema->hasRelation($key) && $this->has($key)) { $this->{$key}->invalidate($value); } ...
php
{ "resource": "" }
q6603
Model.error
train
public function error($field, $all = false) { if (!empty($this->_errors[$field])) { return $all ? $this->_errors[$field] : reset($this->_errors[$field]); } return ''; }
php
{ "resource": "" }
q6604
Model.errored
train
public function errored($field = null) { if (!func_num_args()) { return !!$this->_errors; } return isset($this->_errors[$field]); }
php
{ "resource": "" }
q6605
OciPdoStatementAdapter.bindColumn
train
public function bindColumn($column, &$param, $type = PDO::PARAM_STR, $maxlen = -1, $driverdata = null) { $type = $this->removeBitFlag($$type, PDO::PARAM_INPUT_OUTPUT); $ociParamType = $this->pdo2OciParamConst($type); // LOBs if ($lob_desc = $this->oci_lob_desc($ociParamType)) { $this->_lobs[$this->_lobsCount...
php
{ "resource": "" }
q6606
OciPdoStatementAdapter.fetchObject
train
public function fetchObject($class_name = 'stdClass', array $ctor_args = array()) { $obj = $this->fetch(PDO::FETCH_OBJ); if($class_name == 'stdClass') { $res = $obj; } else { $res = $this->populateObject($obj, $class_name, $ctor_args); } return $res; }
php
{ "resource": "" }
q6607
OciPdoStatementAdapter.getError
train
protected function getError() { if ($this->_error === false) { if (is_resource($this->stmt)) { $this->_error = @oci_error($this->stmt); } else { $this->_error = @oci_error(); } } return $this->_error; }
php
{ "resource": "" }
q6608
OciPdoStatementAdapter.oci_lob_desc
train
public function oci_lob_desc($type) { switch ($type) { case OCI_B_BFILE: $result = OCI_D_FILE; break; case OCI_B_CFILEE: $result = OCI_D_FILE; break; case OCI_B_CLOB: case SQLT_CLOB: case OCI_B_BLOB: case SQLT_BLOB: $result = OCI_D_LOB; break; case OCI_B_ROWID: $result = OCI_D_ROWID; break; de...
php
{ "resource": "" }
q6609
OciPdoStatementAdapter.lobToStream
train
protected function lobToStream(&$lob) { if (is_null($lob)) { return null; } if (is_object($lob) && get_class($lob) == 'OCI-Lob') { return fopen('ocipdolob://', 'r', false, OciPdoLobStreamWrapper::getContext($lob)); } else { return String2Stream::create($lob); } }
php
{ "resource": "" }
q6610
Annotation.parse
train
public static function parse($doc) { $block = new DocBlock(); $lines = explode("\n", $doc); // remove first line unset($lines[0]); foreach ($lines as $line) { $line = trim($line); $line = substr($line, 2); if (isset($line[0]) && $line[0]...
php
{ "resource": "" }
q6611
Annotation.parseAttributes
train
public static function parseAttributes($values) { $result = array(); $values = trim($values, " \t\n\r\0\x0B()"); $parts = explode(',', $values); foreach ($parts as $part) { $kv = explode('=', $part, 2); $key = trim($kv[0]); $value = isset($k...
php
{ "resource": "" }
q6612
SurvStatsCore.loadMapRow
train
protected function loadMapRow() { $ret = [ "cnt" => 0, "rec" => [], "dat" => [] ]; if (sizeof($this->datMap) > 0) { foreach ($this->datMap as $let => $d) { $ret["dat"][$let] = [ "sum" => 0, ...
php
{ "resource": "" }
q6613
Through._merge
train
protected function _merge($data, $exists) { if (!$data) { $this->_parent->get($this->_through)->clear(); return; } $pivot = $this->_parent->{$this->_through}; $relThrough = $this->_parent->schema()->relation($this->_through); $through = $relThrough->...
php
{ "resource": "" }
q6614
Through.set
train
public function set($offset = null, $data = []) { $name = $this->_through; $this->_parent->{$name}->set($offset, $this->_item($data)); return $this; }
php
{ "resource": "" }
q6615
Through.push
train
public function push($data = []) { $name = $this->_through; $this->_parent->{$name}->push($offset, $this->_item($data)); return $this; }
php
{ "resource": "" }
q6616
Through._item
train
protected function _item($data, $options = []) { $name = $this->_through; $parent = $this->_parent; $relThrough = $parent->schema()->relation($name); $through = $relThrough->to(); $id = $this->_parent->id(); $item = $through::create($id !== null ? $relThrough->match($...
php
{ "resource": "" }
q6617
Through.prev
train
public function prev() { $entity = $this->_parent->{$this->_through}->prev(); if ($entity) { return $entity->{$this->_using}; } }
php
{ "resource": "" }
q6618
Through.map
train
public function map($closure) { $data = []; foreach ($this as $val) { $data[] = $closure($val); } return new Collection(compact('data')); }
php
{ "resource": "" }
q6619
Through.reduce
train
public function reduce($closure, $initial = false) { $result = $initial; foreach ($this as $val) { $result = $closure($result, $val); } return $result; }
php
{ "resource": "" }
q6620
Through.validates
train
public function validates($options = []) { $success = true; foreach ($this as $entity) { if (!$entity->validates($options)) { $success = false; } } return $success; }
php
{ "resource": "" }
q6621
Console_Color2.color
train
public function color($color = null, $style = null, $background = null) // {{{ { $colors = $this->getColorCodes(); if (is_array($color)) { $style = isset($color['style']) ? $color['style'] : null; $background = isset($color['background']) ? $color['background'] : null; ...
php
{ "resource": "" }
q6622
Printer.formatExceptionMsg
train
protected function formatExceptionMsg($exceptionMessage) { $exceptionMessage = str_replace("+++ Actual\n", '', $exceptionMessage); $exceptionMessage = str_replace("--- Expected\n", '', $exceptionMessage); $exceptionMessage = str_replace("@@ @@\n", '', $exceptionMessage); $except...
php
{ "resource": "" }
q6623
CheckRoles.attachRoles
train
public function attachRoles($roles) { if ($roles instanceof Role) { $roles = [$roles->getKey()]; } $this->roles()->sync($roles, false); unset($this->relations['roles']); return $this; }
php
{ "resource": "" }
q6624
CheckRoles.detachRoles
train
public function detachRoles($roles) { if ($roles instanceof Role) { $roles = [$roles->getKey()]; } $this->roles()->detach($roles); unset($this->relations['roles']); return $this; }
php
{ "resource": "" }
q6625
Hashids.make
train
public static function make(?string $salt, ?int $length, ?string $alphabet) { $salt = is_null($salt) ? config('hashids.salt') : config('hashids.salt') . $salt; $length = $length ?? config('hashids.length'); $alphabet = $alphabet ?? config('hashids.alphabet'); $salt = \Ill...
php
{ "resource": "" }
q6626
Installer.configureAsRoot
train
public static function configureAsRoot(): void { $filesystem = new Filesystem(); $vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src'; if ($filesystem->exists($vendor_dir)) { return; } self::configure(); $filesystem->mkdir($vendor_dir . '/Hostnet')...
php
{ "resource": "" }
q6627
Installer.execute
train
public function execute(): void { self::configure(); if (false === $this->io->isVerbose()) { return; } $this->io->write('<info>Configured phpcs to use Hostnet standard</info>'); }
php
{ "resource": "" }
q6628
Installer.configure
train
public static function configure(): void { $filesystem = new Filesystem(); $config = [ 'colors' => '1', 'installed_paths' => implode(',', [ Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/', Path::VENDOR_DIR . '/slevomat/coding-standar...
php
{ "resource": "" }
q6629
VerifyCode.configure
train
public function configure($_array = NULL) { if ( $_array != NULL ) { if ( isset( $_array['x'] ) ) $this->_config['x'] = $_array['x']; if ( isset( $_array['y'] ) ) $this->_config['y'] = $_array['y']; if ( isset( $_array['w'] ) ) $this->_config['w'] = $_array['w']; if ( isset( $_array['h'] ) ) $this->_confi...
php
{ "resource": "" }
q6630
MergeCommand.execute
train
protected function execute(InputInterface $input, OutputInterface $output) { // Welcome $output->writeln( '<info>Welcome to the Cypress GitElephantBundle merge command.</info>' ); if ($input->getOption('no-push')) { $output->writeln( '<comment>...
php
{ "resource": "" }
q6631
User.getSearchableRules
train
public function getSearchableRules(): array { return [ 'roles:[]' => function (Builder $query, array $roles) { return $query->whereHas('roles', function (Builder $query) use ($roles) { return $query->whereIn(Role::column('name'), $roles); }); ...
php
{ "resource": "" }
q6632
User.scopeHasRoles
train
public function scopeHasRoles(Builder $query, array $roles = []): Builder { $query->with('roles')->whereNotNull('users.id'); if (! empty($roles)) { $query->whereHas('roles', function ($query) use ($roles) { $query->whereIn(Role::column('name'), $roles); }); ...
php
{ "resource": "" }
q6633
User.scopeHasRolesId
train
public function scopeHasRolesId(Builder $query, array $rolesId = []): Builder { $query->with('roles')->whereNotNull('users.id'); if (! empty($rolesId)) { $query->whereHas('roles', function ($query) use ($rolesId) { $query->whereIn(Role::column('id'), $rolesId); ...
php
{ "resource": "" }
q6634
User.setPasswordAttribute
train
public function setPasswordAttribute(string $value): void { if (Hash::needsRehash($value)) { $value = Hash::make($value); } $this->attributes['password'] = $value; }
php
{ "resource": "" }
q6635
OwnedBy.scopeOwnedBy
train
public function scopeOwnedBy(Builder $query, Model $related, ?string $key = null): Builder { if (\is_null($key)) { $key = $related->getForeignKey(); } return $query->where($key, $related->getKey()); }
php
{ "resource": "" }
q6636
Handler.getEncoding
train
private function getEncoding(string &$string): string { # Check for the UTF-8 byte order mark if (substr($string, 0, 3) === self::UTF8) { $string = substr($string, 3); return self::UTF8; } # Check for the UTF-16 big endian byte order mark if (substr($...
php
{ "resource": "" }
q6637
Handler.convert
train
public function convert(string $string): string { if ($this->encoding === null) { $this->encoding = $this->getEncoding($string); } if ($this->encoding === self::UTF16BE) { $string = mb_convert_encoding($string, "UTF-8", "UTF-16BE"); } if ($this->enco...
php
{ "resource": "" }
q6638
Map.set
train
public function set($value, $data) { $id = is_object($value) ? spl_object_hash($value) : $value; $this->_keys[$id] = $value; $this->_data[$id] = $data; return $this; }
php
{ "resource": "" }
q6639
Map.get
train
public function get($value) { $id = is_object($value) ? spl_object_hash($value) : $value; if (isset($this->_data[$id])) { return $this->_data[$id]; } throw new ORMException("No collected data associated to the key."); }
php
{ "resource": "" }
q6640
Map.delete
train
public function delete($value) { $id = is_object($value) ? spl_object_hash($value) : $value; unset($this->_keys[$id]); unset($this->_data[$id]); return $this; }
php
{ "resource": "" }
q6641
Map.has
train
public function has($value) { $id = is_object($value) ? spl_object_hash($value) : $value; return isset($this->_data[$id]); }
php
{ "resource": "" }
q6642
Bootstrap.setupEnvironment
train
public static function setupEnvironment(Config $config) { if (!defined('PSX')) { // define paths define('PSX_PATH_CACHE', $config->get('psx_path_cache')); define('PSX_PATH_PUBLIC', $config->get('psx_path_public')); define('PSX_PATH_SRC', $config->get('psx_path...
php
{ "resource": "" }
q6643
MenuHelper.setFullBaseUrl
train
public function setFullBaseUrl(array $menu = []): array { $menu = array_map( function ($v) { $url = Hash::get($v, 'url'); $children = Hash::get($v, 'children'); if ($url) { $v['url'] = Router::url($url, true); } ...
php
{ "resource": "" }
q6644
DynamicEntry.getFields
train
public function getFields() { $coercedFields = []; foreach (array_keys($this->entry->getFields()) as $key) { $coercedFields[$key] = $this->getCoercedField($key); } return $coercedFields; }
php
{ "resource": "" }
q6645
AttributeType.getValue
train
public static function getValue($slug, $attributeAvId, $locale = 'en_US') { return self::getValues([$slug], [$attributeAvId], $locale)[$slug][$attributeAvId]; }
php
{ "resource": "" }
q6646
AttributeType.getFirstValues
train
public static function getFirstValues(array $slugs, array $attributeAvIds, $locale = 'en_US') { $results = self::getValues($slugs, $attributeAvIds, $locale); $return = array(); foreach ($slugs as $slug) { if (!isset($return[$slug])) { $return[$slug] = null; ...
php
{ "resource": "" }
q6647
AttributeType.getAttributeAv
train
public static function getAttributeAv($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US') { return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->findOne(); }
php
{ "resource": "" }
q6648
AttributeType.getAttributeAvs
train
public static function getAttributeAvs($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US') { return self::queryAttributeAvs($slugs, $attributeIds, $values, $locale)->find(); }
php
{ "resource": "" }
q6649
SurvData.printAllTableIdFlds
train
public function printAllTableIdFlds($tbl, $flds = []) { $ret = ''; $arr = $this->getAllTableIdFlds($tbl, $flds); if (sizeof($arr) > 0) { foreach ($arr as $i => $row) { $ret .= ' (( '; if (sizeof($row) > 0) { foreach ($row as $fl...
php
{ "resource": "" }
q6650
MenuFactory.getMenu
train
public static function getMenu(string $name, array $user, bool $fullBaseUrl = false, $context = null): MenuInterface { $instance = new self($user, $fullBaseUrl); return $instance->getMenuByName($name, $context); }
php
{ "resource": "" }
q6651
MenuFactory.addToMenu
train
public static function addToMenu(MenuInterface $menu, array $items): void { $normalisedItems = self::normaliseItems($items); foreach ($normalisedItems as $item) { $menu->addMenuItem(MenuItemFactory::createMenuItem($item)); } }
php
{ "resource": "" }
q6652
MenuFactory.createMenu
train
public static function createMenu(array $menu): MenuInterface { $menuInstance = new Menu(); self::addToMenu($menuInstance, $menu); return $menuInstance; }
php
{ "resource": "" }
q6653
MenuFactory.getMenuByName
train
protected function getMenuByName(string $name, $context = null): MenuInterface { // validate menu name $this->validateName($name); // get menu $menuEntity = null; try { $menuEntity = $this->Menus ->find('all') ->where(['name' => $n...
php
{ "resource": "" }
q6654
MenuFactory.getMenuItemsFromEvent
train
protected function getMenuItemsFromEvent(string $menuName, array $modules = [], $subject = null): MenuInterface { if (empty($subject)) { $subject = $this; } $event = new Event((string)EventName::GET_MENU_ITEMS(), $subject, [ 'name' => $menuName, 'user' =>...
php
{ "resource": "" }
q6655
MenuFactory.getMenuItemsFromTable
train
protected function getMenuItemsFromTable(EntityInterface $menu): array { $query = $this->MenuItems->find('threaded', [ 'conditions' => ['MenuItems.menu_id' => $menu->id], 'order' => ['MenuItems.lft'] ]); if ($query->isEmpty()) { return []; } ...
php
{ "resource": "" }
q6656
MenuFactory.getMenuItem
train
protected function getMenuItem(EntityInterface $menu, array $item, int $order = 0): array { if (empty($item)) { return []; } $label = $item['label']; $icon = $item['icon']; $type = $item['type']; $children = !empty($item['children']) ? $item['children'] ...
php
{ "resource": "" }
q6657
MenuFactory.applyDefaults
train
public static function applyDefaults(array $items, array $defaults = null): array { $defaults = empty($defaults) ? Configure::readOrFail('Menu.defaults') : $defaults; // merge item properties with defaults $func = function (&$item, $k) use (&$func, $defaults) { if (!empty($item[...
php
{ "resource": "" }
q6658
MenuFactory.normaliseItems
train
public static function normaliseItems(array $items): array { // merge item properties with defaults $items = self::applyDefaults($items); // merge duplicated labels recursively $result = []; foreach ($items as $item) { if (!array_key_exists($item['label'], $resul...
php
{ "resource": "" }
q6659
MenuFactory.sortItems
train
protected function sortItems(array $items, string $key = 'order'): array { $cmp = function (&$a, &$b) use (&$cmp, $key) { if (!empty($a['children'])) { usort($a['children'], $cmp); } if (!empty($b['children'])) { usort($b['children'], $cmp...
php
{ "resource": "" }
q6660
ClassBasedNameTrait.getName
train
public function getName() { //generate snake case name based on class name preg_match('/\\\?(\w+)Filter$/', get_class($this), $matches); return ltrim(strtolower(strval(preg_replace('/[A-Z]/', '_$0', $matches[1]))), '_'); }
php
{ "resource": "" }
q6661
RabbitMQWorkerTask.consume
train
public function consume($config, callable $callable) { $this->ProcessManager->handleKillSignals(); $this->eventManager()->attach([$this, 'signalHandler'], 'CLI.signal', ['priority' => 100]); $this->_consume(Queue::consume($config), $callable); }
php
{ "resource": "" }
q6662
RabbitMQWorkerTask._callback
train
protected function _callback(callable $callable, AMQPEnvelope $envelope, AMQPQueue $queue) { if ($this->stop) { return false; } if ($envelope === false) { return false; } if ($this->stop) { $this->log('-> Putting job back into the queue',...
php
{ "resource": "" }
q6663
RabbitMQWorkerTask.signalHandler
train
public function signalHandler() { if (!$this->_working) { $this->log('Not doing any jobs, going to die now...', 'warning'); $this->_stop(); return; } $this->stop = true; }
php
{ "resource": "" }
q6664
Kernel.observes
train
public function observes() { foreach (config('observers') as $observer => $models) { foreach ($models as $model) { if (class_exists($model) && class_exists($observer)) { $model::observe($observer); } } } }
php
{ "resource": "" }
q6665
UploadService.validatesUploadedFile
train
public function validatesUploadedFile($validate = null) { if (func_num_args() === 0) { return $this->validatesUploadedFile; } return $this->validatesUploadedFile = (bool)$validate; }
php
{ "resource": "" }
q6666
UploadService.prepareUploadData
train
protected function prepareUploadData(UploadedFile $uploadedFile) { return [ 'extension' => $uploadedFile->getClientOriginalExtension(), 'mimetype' => $uploadedFile->getMimeType(), 'size' => $uploadedFile->getSize(), 'name' => $uploadedFile->getClien...
php
{ "resource": "" }
q6667
UploadService.getUploadPath
train
public function getUploadPath() { $relativePath = date('Y/m'); $fullPath = upload_path($relativePath); $this->makeUploadPath($fullPath); return [$fullPath, $relativePath]; }
php
{ "resource": "" }
q6668
UploadService.getNewUploadModel
train
protected function getNewUploadModel($id = null) { $uploadModel = $this->modelName(); $upload = new $uploadModel; if ( ! $upload instanceof Uploadable) { throw new RuntimeException('The upload model must implement the "Kenarkose\Transit\Contract\Uploadable" interface.')...
php
{ "resource": "" }
q6669
TreeSurvFormVarieties.widgetCust
train
public function widgetCust(Request $request, $nID = -3) { $this->survLoopInit($request, ''); $this->loadAllSessData(); //$this->loadTree(); $txt = (($request->has('txt')) ? trim($request->get('txt')) : ''); $nIDtxt = $nID . $txt; $branches = (($request->has('branch'))...
php
{ "resource": "" }
q6670
AttributeAttributeTypeQuery.filterByAttributeId
train
public function filterByAttributeId($attributeId = null, $comparison = null) { if (is_array($attributeId)) { $useMinMax = false; if (isset($attributeId['min'])) { $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER...
php
{ "resource": "" }
q6671
AttributeAttributeTypeQuery.filterByAttributeTypeId
train
public function filterByAttributeTypeId($attributeTypeId = null, $comparison = null) { if (is_array($attributeTypeId)) { $useMinMax = false; if (isset($attributeTypeId['min'])) { $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId[...
php
{ "resource": "" }
q6672
AttributeAttributeTypeQuery.filterByAttribute
train
public function filterByAttribute($attribute, $comparison = null) { if ($attribute instanceof \Thelia\Model\Attribute) { return $this ->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); } elseif ($attribute instanceof ObjectCol...
php
{ "resource": "" }
q6673
AttributeAttributeTypeQuery.useAttributeQuery
train
public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttribute($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); }
php
{ "resource": "" }
q6674
AttributeAttributeTypeQuery.joinAttributeType
train
public function joinAttributeType($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('AttributeType'); // create a ModelJoin object for this join $join = new ModelJoin(); $join->setJoinType($join...
php
{ "resource": "" }
q6675
AttributeAttributeTypeQuery.filterByAttributeTypeAvMeta
train
public function filterByAttributeTypeAvMeta($attributeTypeAvMeta, $comparison = null) { if ($attributeTypeAvMeta instanceof \AttributeType\Model\AttributeTypeAvMeta) { return $this ->addUsingAlias(AttributeAttributeTypeTableMap::ID, $attributeTypeAvMeta->getAttributeAttributeType...
php
{ "resource": "" }
q6676
AttributeAttributeTypeQuery.useAttributeTypeAvMetaQuery
train
public function useAttributeTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttributeTypeAvMeta($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'AttributeTypeAvMeta', '\AttributeType\Model\AttributeTypeAvMetaQuery'...
php
{ "resource": "" }
q6677
Image.show
train
public function show() { switch ( $this->extension ) { case 'jpg': case 'jpeg': header("Content-type: image/jpeg"); imagejpeg($this->imgDst); break; case 'gif': header("Content-type: image/gif"); ...
php
{ "resource": "" }
q6678
GitElephantRepositoryCollection.get
train
public function get($name) { /** @var Repository $repository */ foreach ($this->repositories as $repository) { if ($repository->getName() == $name) { return $repository; } } return null; }
php
{ "resource": "" }
q6679
RestFormAction.cleanForm
train
private function cleanForm($requestData, Form $form) { $allowedField = array_keys($requestData); /** @var FormInterface[] $formFields */ $formFields = $form->all(); foreach ($formFields as $formField) { $fieldName = $formField->getName(); if (!in_array($fiel...
php
{ "resource": "" }
q6680
DefaultContainer.newLoggerHandlerImpl
train
protected function newLoggerHandlerImpl() { $config = $this->get('config'); $factory = $config->get('psx_logger_factory'); if ($factory instanceof \Closure) { return $factory($config); } else { $level = $config->get('psx_log_level'); $level = !em...
php
{ "resource": "" }
q6681
DefaultContainer.newDoctrineCacheImpl
train
protected function newDoctrineCacheImpl($namespace) { $config = $this->get('config'); $factory = $config->get('psx_cache_factory'); if ($factory instanceof \Closure) { return $factory($config, $namespace); } else { return new DoctrineCache\FilesystemCache($t...
php
{ "resource": "" }
q6682
AddTaggedCompilerPass.getServiceArgument
train
private function getServiceArgument(ContainerBuilder $container, string $id) { if ($this->callMode === self::CALL_MODE_ID) { $container->getDefinition($id)->setPublic(true); return $id; } if ($this->callMode === self::CALL_MODE_LAZY_SERVICE) { $container...
php
{ "resource": "" }
q6683
Script.getRequestData
train
protected function getRequestData() { return [ 'request' => $this->request->toArray(), 'response' => [ 'content' => null, 'content_type' => null, 'status_code' => ServiceResponseInterface::HTTP_OK ], 'reso...
php
{ "resource": "" }
q6684
ConfigProvider.getFilterConfig
train
public function getFilterConfig(): array { return [ 'aliases' => [ 'singlespaces' => Filter\SingleSpaces::class, 'singleSpaces' => Filter\SingleSpaces::class, 'SingleSpaces' => Filter\SingleSpaces::class, 'transliteration' ...
php
{ "resource": "" }
q6685
TypeFactory.create
train
public static function create(string $type): \Menu\Type\TypeInterface { if (empty($type)) { throw new InvalidArgumentException('Type must be a non-empty string.'); } $className = __NAMESPACE__ . '\\Types\\' . Inflector::camelize($type); if (!class_exists($className)) { ...
php
{ "resource": "" }
q6686
TypeFactory.getList
train
public static function getList(): array { $result = []; $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Types'; $dir = new Folder($path); $files = $dir->find('.*\.php'); if (empty($files)) { return $result; } foreach ($files as $file) { ...
php
{ "resource": "" }
q6687
ResponseWriter.setBody
train
public function setBody(ResponseInterface $response, $data, $writerType = null) { if ($data instanceof HttpResponseInterface) { $statusCode = $data->getStatusCode(); if (!empty($statusCode)) { $response->setStatus($statusCode); } $headers = $d...
php
{ "resource": "" }
q6688
ResponseWriter.getWriterOptions
train
protected function getWriterOptions(RequestInterface $request) { $options = new WriterOptions(); $options->setContentType($request->getHeader('Accept')); $options->setFormat($request->getUri()->getParameter('format')); $options->setSupportedWriter($this->supportedWriter); $op...
php
{ "resource": "" }
q6689
Relationship.counterpart
train
public function counterpart() { if ($this->_counterpart) { return $this->_counterpart; } $to = $this->to(); $from = $this->from(); $relations = $to::definition()->relations(); $result = []; foreach ($relations as $relation) { $rel = ...
php
{ "resource": "" }
q6690
Relationship._find
train
protected function _find($id, $options = []) { $defaults = [ 'query' => [], 'fetchOptions' => [] ]; $options += $defaults; $fetchOptions = $options['fetchOptions']; unset($options['fetchOptions']); if ($this->link() !== static::LINK_KE...
php
{ "resource": "" }
q6691
Relationship._index
train
protected function _index($collection, $name) { $indexes = []; foreach ($collection as $key => $entity) { if (is_object($entity)) { if ($entity->{$name}) { $indexes[(string) $entity->{$name}] = $key; } } else { ...
php
{ "resource": "" }
q6692
Relationship._cleanup
train
public function _cleanup(&$collection) { $name = $this->name(); if ($this->isMany()) { foreach ($collection as $index => $entity) { if (is_object($entity)) { $entity->{$name} = []; } else { $collection[$index][$name...
php
{ "resource": "" }
q6693
Relationship.validates
train
public function validates($entity, $options = []) { $fieldname = $this->name(); if (!isset($entity->{$fieldname})) { return true; } return $entity->{$fieldname}->validates($options); }
php
{ "resource": "" }
q6694
Authenticate.redirectTo
train
protected function redirectTo($request) { session()->put('loginRedir', $_SERVER["REQUEST_URI"]); session()->put('loginRedirTime', time()); if (!$request->expectsJson()) { return route('login'); } }
php
{ "resource": "" }
q6695
CreateModelCommand.promptMigration
train
protected function promptMigration($name) { $this->line(''); if ($this->confirm('Would you like to create the migration for the model? [Yes|no]')) { $this->call('transit:migration', ['table' => str_plural($name)]); } }
php
{ "resource": "" }
q6696
CompositeAssetDecorator.decorate
train
public function decorate(AssetInterface $asset) { foreach ($this->decorators as $decorator) { /** * @var AssetDecoratorInterface $decorator */ $asset = $decorator->decorate($asset); } return $asset; }
php
{ "resource": "" }
q6697
HttpRequest.getParameter
train
public function getParameter( $name, $func_str=null, $setParam=true ) { if ( !$func_str ) return urldecode($this->parameters[$name]) ? urldecode($this->parameters[$name]) : $this->parameters[$name]; $funcs = explode("|", $func_str); $args = urldecode($this->parameters[$name]); foreach ( $fun...
php
{ "resource": "" }
q6698
FileUpload.upload
train
public function upload($_field, $_base64 = false) { if ( !$this->checkUploadDir() ) { $this->errNum = 6; return false; } if ( $_base64 ) { $_data = $_POST[$_field]; return $this->makeBase64Image( $_data ); } $_localFile = $_FILES[$_field]['name']; if ( !$_l...
php
{ "resource": "" }
q6699
AttributeTypeAvMeta.setAttributeAv
train
public function setAttributeAv(ChildAttributeAv $v = null) { if ($v === null) { $this->setAttributeAvId(NULL); } else { $this->setAttributeAvId($v->getId()); } $this->aAttributeAv = $v; // Add binding for other direction of this n:n relationship. ...
php
{ "resource": "" }