_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 ]; $options += $defaults; $validator = static::validator(); $valid = $this->_validates(['embed' => $options['embed']]); $success = $validator->validates($this->get(), $options); $this->_errors = []; $this->invalidate($validator->errors()); return $success && $valid; }
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']); $success = true; foreach ($tree as $field => $value) { if (isset($this->{$field})) { $rel = $schema->relation($field); $success = $success && $rel->validates($this, $value ? $value + $options : $options); } } return $success; }
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); } else { $this->invalidate($key, $value); } } return $this; } if ($errors) { $this->_errors[$field] = (array) $errors; } return $this; }
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]['type'] = $ociParamType; $this->_lobs[$this->_lobsCount]['lob'] = @oci_new_descriptor($this->ociPdoAdapter->getOciConnection(), $lob_desc); $res = $this->_lobs[$this->_lobsCount]['lob']; $this->checkError($res); $res = @oci_define_by_name($this->stmt, $column, $this->_lobs[$this->_lobsCount]['lob'], $ociParamType); $this->checkError($res); $this->_lobs[$this->_lobsCount]['var'] = $param; $this->_lobs[$this->_lobsCount]['input'] = false; $this->_lobsCount++; } else { $res = @oci_define_by_name($this->stmt, $column, $param, $ociParamType); $this->checkError($res); } return $res; }
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; default: $result = false; break; } return $result; }
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] == '@') { $line = substr($line, 1); $sp = strpos($line, ' '); $bp = strpos($line, '('); if ($sp !== false || $bp !== false) { if ($sp !== false && $bp === false) { $pos = $sp; } elseif ($sp === false && $bp !== false) { $pos = $bp; } else { $pos = $sp < $bp ? $sp : $bp; } $key = substr($line, 0, $pos); $value = substr($line, $pos); } else { $key = $line; $value = null; } $key = trim($key); $value = trim($value); if (!empty($key)) { // if key contains backslashes its a namespace use only the // short name $pos = strrpos($key, '\\'); if ($pos !== false) { $key = substr($key, $pos + 1); } $block->addAnnotation($key, $value); } } } return $block; }
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($kv[1]) ? $kv[1] : ''; $value = trim($value, " \t\n\r\0\x0B\""); if (!empty($key)) { $result[$key] = $value; } } return $result; }
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, "avg" => 0, "ids" => [] ]; } } return $ret; }
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->to(); $schema = $through::definition(); $rel = $schema->relation($this->_using); $fromKey = $rel->keys('from'); $toKey = $rel->keys('to'); $i = 0; while ($i < $pivot->count()) { $found = false; $entity = $pivot->get($i); $id1 = $entity->get($fromKey); if ($id1 === null) { $pivot->splice($i, 1); continue; } foreach ($data as $key => $item) { $isDocument = $item instanceof Document; $id2 = $isDocument ? $item->get($toKey) : (isset($item[$toKey]) ?$item[$toKey] : null); if ((string) $id1 === (string) $id2) { if ($isDocument) { $entity->set($this->_using, $item); } else { $entity->get($this->_using)->amend($item); } unset($data[$key]); $i++; $found = true; break; } } if (!$found) { $pivot->splice($i, 1); } } foreach ($data as $entity) { $this[] = $entity; } }
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($this->_parent) : [], $options); $item->setAt($this->_using, $data, $options); return $item; }
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; $color = isset($color['color']) ? $color['color'] : null; } if ($color == 'reset') { return "\033[0m"; } $code = array(); if (isset($style)) { $code[] = $colors['style'][$style]; } if (isset($color)) { $code[] = $colors['color'][$color]; } if (isset($background)) { $code[] = $colors['background'][$background]; } if (empty($code)) { $code[] = 0; } $code = implode(';', $code); return "\033[{$code}m"; }
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); $exceptionMessage = preg_replace("/(Failed.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage); $exceptionMessage = preg_replace("/\-+(.*)$/m", "\n \033[01;32m$1\033[0m", $exceptionMessage); return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage); }
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 = \Illuminate\Support\Facades\Hash::make($salt); return new self($salt, $length, $alphabet); }
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'); $filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs'); $filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml'); $filesystem->mkdir($vendor_dir . '/HostnetPaths'); $filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml'); }
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-standard/SlevomatCodingStandard', ]), ]; if (!$filesystem->exists(['phpcs.xml', 'phpcs.xml.dist'])) { $config['default_standard'] = 'Hostnet'; } $filesystem->dumpFile( Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf', sprintf('<?php $phpCodeSnifferConfig = %s;', var_export($config, true)) ); $filesystem->dumpFile(__DIR__ . '/../../../HostnetPaths/ruleset.xml', self::generateHostnetPathsXml()); }
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->_config['h'] = $_array['h']; if ( isset( $_array['f'] ) ) $this->_config['f'] = $_array['f']; } return self::$_instance; }
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>--no-push option enabled (this option disable push destination branch to remotes)</comment>' ); } /** @var GitElephantRepositoryCollection $rc */ $rc = $this->getContainer()->get('git_repositories'); if ($rc->count() == 0) { throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use'); } /** @var Repository $repository */ foreach ($rc as $key => $repository) { if ($key == 0 || $key > 0 && $input->getOption('all')) { /** @var Branch $source */ $source = $repository->getBranch($input->getArgument('source')); if (is_null($source)) { throw new \Exception('Source branch ' . $input->getArgument('source') . ' doesn\'t exists'); } /** @var Branch $destination */ $destination = $repository->getBranch($input->getArgument('destination')); if (is_null($destination)) { throw new \Exception('Destination branch ' . $input->getArgument('destination') . ' doesn\'t exists'); } $repository->checkout($destination->getName()); $repository->merge($source, '', (!$input->getOption('fast-forward') ? 'no-ff' : 'ff-only')); if (!$input->getOption('no-push')) { /** @var Remote $remote */ foreach ($repository->getRemotes() as $remote) { $repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push destination branch to all remotes } } $repository->checkout($input->getArgument('source')); $output->writeln('Merge from ' . $input->getArgument('source') . ' branch to ' . $input->getArgument('destination') . ' done' . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : '')); } } }
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); }); } return $query; }
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); }); } return $query; }
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($string, 0, 2) === self::UTF16BE) { $string = substr($string, 2); return self::UTF16BE; } # Check for the UTF-16 little endian byte order mark if (substr($string, 0, 2) === self::UTF16LE) { $string = substr($string, 2); return self::UTF16LE; } return self::UNKNOWN; }
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->encoding === self::UTF16LE) { $string = mb_convert_encoding($string, "UTF-8", "UTF-16LE"); } return $string; }
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_src') ?: $config->get('psx_path_library')); /** @deprecated */ define('PSX_PATH_LIBRARY', $config->get('psx_path_library')); // error handling if ($config['psx_debug'] === true) { $errorReporting = E_ALL | E_STRICT; } else { $errorReporting = 0; } error_reporting($errorReporting); set_error_handler('\PSX\Framework\Bootstrap::errorHandler'); // annotation autoload $namespaces = $config->get('psx_annotation_autoload'); if (!empty($namespaces) && is_array($namespaces)) { self::registerAnnotationLoader($namespaces); } // ini settings ini_set('date.timezone', $config['psx_timezone']); ini_set('session.use_only_cookies', '1'); ini_set('docref_root', ''); ini_set('html_errors', '0'); // define in psx define('PSX', true); } }
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); } if (is_array($children)) { $v['children'] = $this->setFullBaseUrl($children); } return $v; }, $menu ); return $menu; }
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; } foreach ($results[$slug] as $value) { if ($return[$slug] === null) { $return[$slug] = $value; continue; } break; } } return $return; }
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 $fld => $val) { $ret .= (($fld != 'id') ? ' , ' : '') . $fld . ' : ' . $val; } } $ret .= ' )) '; } } return $ret; }
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' => $name]) ->firstOrFail(); if (!($menuEntity instanceof EntityInterface)) { throw new RuntimeException(sprintf( 'Expected value of type "Cake\Datasource\EntityInterface", got "%s" instead', gettype($menuEntity) )); } $menuInstance = $menuEntity->get('default') ? $this->getMenuItemsFromEvent($name, [], $context) : $this->getMenuItemsFromTable($menuEntity); } catch (RecordNotFoundException $e) { $menuInstance = static::getMenuItemsFromEvent($name, [], $context); } // maintain backwards compatibility for menu arrays if (is_array($menuInstance)) { $menuInstance = self::normaliseItems($menuInstance); if ($menuEntity instanceof EntityInterface && $menuEntity->get('default')) { $menuInstance = $this->sortItems($menuInstance); } $menuInstance = self::createMenu($menuInstance); } return $menuInstance; }
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' => $this->user, 'fullBaseUrl' => $this->fullBaseUrl, 'modules' => $modules ]); $this->getEventManager()->dispatch($event); return ($event->result instanceof MenuInterface) ? $event->result : new Menu(); }
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 []; } $result = []; $count = 0; foreach ($query->all() as $entity) { $item = $this->getMenuItem($menu, $entity->toArray(), ++$count); if (empty($item)) { continue; } $result[] = $item; } return $result; }
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'] : []; if (!empty($children)) { $count = 0; foreach ($children as $key => $child) { $children[$key] = $this->getMenuItem($menu, $child, ++$count); } } if (static::TYPE_MODULE === $type) { $item = $this->getMenuItemsFromEvent($menu->get('name'), [$item['url']]); reset($item); $item = current($item); } if (!empty($children)) { $item['children'] = $children; } if (empty($item)) { return []; } if (static::TYPE_MODULE === $type) { $item['label'] = $label; $item['icon'] = $icon; } $item['order'] = $order; return $item; }
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['children'])) { array_walk($item['children'], $func); } $item = array_merge($defaults, $item); }; array_walk($items, $func); return $items; }
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'], $result)) { $result[$item['label']] = $item; continue; } $result[$item['label']]['children'] = array_merge_recursive( $item['children'], $result[$item['label']]['children'] ); } return $result; }
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); } return $a[$key] > $b[$key]; }; usort($items, $cmp); return $items; }
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', 'warning'); $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE); return false; } $result = false; try { $this->_working = true; $body = $envelope->getBody(); $compressed = $envelope->getContentEncoding() === 'gzip'; if ($compressed) { $body = gzuncompress($body); } switch ($envelope->getContentType()) { case 'application/json': $result = $callable(json_decode($body, true), $envelope, $queue); break; case 'application/text': $result = $callable($body, $envelope, $queue); break; default: throw new RuntimeException('Unknown serializer: ' . $envelope->getContentType()); } } catch (Exception $e) { $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE); throw $e; } finally { $this->_working = false; } if ($result !== false) { return $queue->ack($envelope->getDeliveryTag()); } return $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE); }
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->getClientOriginalName(), ]; }
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.'); } if ($id) { $upload->setKey($id); } return $upload; }
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')) ? trim($request->get('branch')) : ''); $this->sessData->loadDataBranchFromUrl($branches); return $this->widgetCustomRun($nID, $nIDtxt); }
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_EQUAL); $useMinMax = true; } if (isset($attributeId['max'])) { $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attributeId, $comparison); }
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['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeTypeId['max'])) { $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_TYPE_ID, $attributeTypeId, $comparison); }
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 ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(AttributeAttributeTypeTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } }
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($joinType); $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); if ($previousJoin = $this->getPreviousJoin()) { $join->setPreviousJoin($previousJoin); } // add the ModelJoin to the current object if ($relationAlias) { $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { $this->addJoinObject($join, 'AttributeType'); } return $this; }
php
{ "resource": "" }
q6675
AttributeAttributeTypeQuery.filterByAttributeTypeAvMeta
train
public function filterByAttributeTypeAvMeta($attributeTypeAvMeta, $comparison = null) { if ($attributeTypeAvMeta instanceof \AttributeType\Model\AttributeTypeAvMeta) { return $this ->addUsingAlias(AttributeAttributeTypeTableMap::ID, $attributeTypeAvMeta->getAttributeAttributeTypeId(), $comparison); } elseif ($attributeTypeAvMeta instanceof ObjectCollection) { return $this ->useAttributeTypeAvMetaQuery() ->filterByPrimaryKeys($attributeTypeAvMeta->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByAttributeTypeAvMeta() only accepts arguments of type \AttributeType\Model\AttributeTypeAvMeta or Collection'); } }
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"); imagegif($this->imgDst); break; case 'png': header("Content-type: image/png"); imagepng($this->imgDst); break; default: die("No image support in this PHP server"); } return $this; }
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($fieldName, $allowedField)) { $form->remove($fieldName); } } }
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 = !empty($level) ? $level : Logger::ERROR; $handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level, true, true); $handler->setFormatter(new ErrorFormatter()); return $handler; } }
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($this->get('config')->get('psx_path_cache') . '/' . $namespace); } }
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->getDefinition($id)->setLazy(true); } return new Reference($id); }
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 ], 'resource' => $this->resourcePath ]; }
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' => Filter\Transliteration::class, 'Transliteration' => Filter\Transliteration::class, 'filenamesafe' => Filter\FilenameSafe::class, 'filenameSafe' => Filter\FilenameSafe::class, 'FilenameSafe' => Filter\FilenameSafe::class, ], 'factories' => [ Filter\SingleSpaces::class => InvokableFactory::class, Filter\Transliteration::class => InvokableFactory::class, Filter\FilenameSafe::class => InvokableFactory::class, ], ]; }
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)) { throw new RuntimeException('Class [' . $className . '] does not exist.'); } $interface = __NAMESPACE__ . '\\' . static::INTERFACE_CLASS; if (!in_array($interface, class_implements($className))) { throw new RuntimeException('Class [' . $className . '] must implement [' . $interface . '] interface.'); } return new $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) { $name = str_replace('.php', '', $file); $value = Inflector::underscore($name); $result[$value] = $name; } return $result; }
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 = $data->getHeaders(); if (!empty($headers)) { $response->setHeaders($headers); } $body = $data->getBody(); } else { $body = $data; } if (!GraphTraverser::isEmpty($body)) { if ($writerType instanceof WriterOptions) { $options = $writerType; } elseif ($writerType instanceof RequestInterface) { $options = $this->getWriterOptions($writerType); } elseif (is_string($writerType)) { $options = new WriterOptions(); $options->setWriterType($writerType); } else { $options = new WriterOptions(); $options->setWriterType(WriterInterface::JSON); } $writer = null; if ($body instanceof HttpWriter\WriterInterface) { $writer = $body; } elseif ($body instanceof \DOMDocument) { $writer = new HttpWriter\Xml($body); } elseif ($body instanceof \SimpleXMLElement) { $writer = new HttpWriter\Xml($body); } elseif ($body instanceof StreamInterface) { $writer = new HttpWriter\Stream($body); } elseif (is_string($body)) { $writer = new HttpWriter\Writer($body); } // set new response body since we want to discard every data which // was written before because this could corrupt our output format $response->setBody(new StringStream()); if ($writer instanceof HttpWriter\WriterInterface) { $writer->writeTo($response); } else { $this->setResponse($response, $body, $options ?? new WriterOptions()); } } else { $response->setStatus(204); $response->setBody(new StringStream('')); } }
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); $options->setWriterCallback(function(WriterInterface $writer) use ($request){ if ($writer instanceof Writer\Jsonp) { if (!$writer->getCallbackName()) { $writer->setCallbackName($request->getUri()->getParameter('callback')); } } }); return $options; }
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 = $to::definition()->relation($relation); if ($rel->to() === $this->from()) { $result[] = $rel; } } if (count($result) === 1) { return $this->_counterpart = reset($result); } elseif (count($result) > 1) { throw new ORMException("Ambiguous {$this->type()} counterpart relationship for `{$from}`. Apply the Single Table Inheritance pattern to get unique models."); } throw new ORMException("Missing {$this->type()} counterpart relationship for `{$from}`. Add one in the `{$to}` model."); }
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_KEY) { throw new ORMException("This relation is not based on a foreign key."); } $to = $this->to(); $schema = $to::definition(); if (!$id) { return $to::create([], ['type' => 'set']); } $ids = is_array($id) ? $id : [$id]; $key = $schema->key(); $column = $schema->column($key); foreach ($ids as $i => $value) { $ids[$i] = $schema->convert('cast', $column['type'], $value, $column); } if (count($ids) === 1) { $ids = reset($ids); } $conditions = [$this->keys('to') => $ids]; if ($this->conditions()) { $conditions = [ ':and()' => [ [$this->keys('to') => $ids], $this->conditions() ] ]; } $query = Set::extend($options['query'], ['conditions' => $conditions]); return $to::all($query, $fetchOptions); }
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 { if (isset($entity[$name])) { $indexes[(string) $entity[$name]] = $key; } } } return $indexes; }
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] = []; } } return; } foreach ($collection as $index => $entity) { if (is_object($entity)) { unset($entity->{$name}); } else { unset($entity[$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 ( $funcs as $func ) { $args = call_user_func($func, $args); } if ( $setParam ) { $this->parameters[$name] = $args; } return $args; }
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 ( !$_localFile ) { $this->errNum = 10; return false; } $_tempFile = $_FILES[$_field]['tmp_name'];//原来是这样 //$_tempFile = str_replace('\\\\', '\\', $_FILES[$_field]['tmp_name']);//MAGIC_QUOTES_GPC=OFF时,做了这样处理:$_FILES = daddslashes($_FILES);图片上传后tmp_name值变成 X:\\Temp\\php668E.tmp,结果move_uploaded_file() 函数判断为不合法的文件而返回FALSE。 $_error_no = $_FILES[$_field]['error']; $this->fileInfo['file_type'] = $_FILES[$_field]['type']; $this->fileInfo['local_name'] = $_localFile; $this->fileInfo['file_size'] = $_FILES[$_field]['size']; $this->errNum = $_error_no; if ( $this->errNum == 0 ) { $this->checkFileType($_localFile); if ( $this->errNum == 0 ) { $this->checkFileSize($_tempFile); if ( $this->errNum == 0 ) { if ( is_uploaded_file($_tempFile) ) { $_new_filename = $this->getFileName($_localFile); $this->fileInfo['file_path'] = $this->config['upload_dir'].DIRECTORY_SEPARATOR.$_new_filename; if ( move_uploaded_file($_tempFile, $this->fileInfo['file_path']) ) { $_filename = $_new_filename; $this->fileInfo['file_name'] = $_filename; $pathinfo = pathinfo($this->fileInfo['file_path']); $this->fileInfo['file_ext'] = $pathinfo['extension']; $this->fileInfo['raw_name'] = $pathinfo['filename']; return $this->fileInfo; } else { $this->errNum = 7; } } } } } return false; }
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. // If this object has already been added to the ChildAttributeAv object, it will not be re-added. if ($v !== null) { $v->addAttributeTypeAvMeta($this); } return $this; }
php
{ "resource": "" }