_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q30500
Position.respondSuccess
train
protected function respondSuccess($model) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return [ 'success' => true ]; } return $this->controller->redirect($this->createReturnUrl('view', $model)); ...
php
{ "resource": "" }
q30501
Document.get
train
public function get($pointer) { $pointer = new Pointer($pointer); $data = $pointer->evaluate($this->_properties); return $data; }
php
{ "resource": "" }
q30502
Document.patch
train
public function patch(array $operations) { $patch = new Patch($operations); $data = $patch->patch($this->_properties); $this->_properties = $data; }
php
{ "resource": "" }
q30503
FigletManager.render
train
public static function render($string, $fontName) { if (!in_array($fontName, static::getKnownFonts())) { throw new Exception("Error unknown font ID fontID"); } $figletString = FigletEngine::create($string, $fontName); return $figletString; }
php
{ "resource": "" }
q30504
SlotManager.setUpBlockManagers
train
public function setUpBlockManagers(array $blocks) { foreach ($blocks as $block) { $blockManager = $this->blockManagerFactory->createBlockManager($block); if (null === $blockManager) { continue; } $this->blockManagersCollection->addBlockManager(...
php
{ "resource": "" }
q30505
OptionsParser.buildValue
train
protected function buildValue(&$value, $key) { if (in_array($key, $this->toBeExploded)) { //Collapses multi-dimensional arrays into a single dimension $value = array_clean(is_array($value) ? Hash::flatten($value) : explode(' ', $value)); sort($value); $value =...
php
{ "resource": "" }
q30506
OptionsParser.add
train
public function add($key, $value = null) { if (is_array($key)) { array_map([$this, __METHOD__], array_keys($key), $key); return $this; } $this->options[$key] = $this->buildValue($value, $key); return $this; }
php
{ "resource": "" }
q30507
OptionsParser.addButtonClasses
train
public function addButtonClasses($classes = 'btn-light') { $baseClasses = [ 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', 'link']; $allClasses = array_merge($baseClasses, ['outline-primary', 'outline-secondary', 'outline-success', 'outline-d...
php
{ "resource": "" }
q30508
OptionsParser.append
train
public function append($key, $value = null) { if (is_array($key)) { array_map([$this, __METHOD__], array_keys($key), $key); return $this; } $existing = $this->get($key); if (in_array($key, $this->toBeExploded)) { $existing = explode(' ', $existi...
php
{ "resource": "" }
q30509
OptionsParser.consume
train
public function consume($key) { $value = $this->get($key); $this->delete($key); return $value; }
php
{ "resource": "" }
q30510
OptionsParser.contains
train
public function contains($key, $value) { if (!$this->exists($key)) { return false; } $existing = $this->get($key); $existing = in_array($key, $this->toBeExploded) ? explode(' ', $existing) : $existing; if (is_array($existing)) { if (is_array($value))...
php
{ "resource": "" }
q30511
OptionsParser.get
train
public function get($key) { $default = $this->Default ? $this->Default->get($key) : null; return Hash::get($this->options, $key, $default); }
php
{ "resource": "" }
q30512
OptionsParser.toArray
train
public function toArray() { $options = $this->options; if ($this->Default) { $options = array_merge($this->Default->options, $options); } ksort($options); return $options; }
php
{ "resource": "" }
q30513
OptionsParser.toString
train
public function toString() { $options = $this->toArray(); //Transforms values as strings array_walk($options, function (&$value, $key) { if (is_array($value)) { $value = implode(' ', $value); } elseif (is_bool($value)) { $value = $valu...
php
{ "resource": "" }
q30514
OptionsParser.tooltip
train
public function tooltip() { $tooltip = $this->consume('tooltip'); if (!$tooltip) { return $this; } $this->append('data-toggle', 'tooltip'); $this->add('title', trim(h(strip_tags($tooltip)))); if ($this->exists('tooltip-align')) { $this->add(...
php
{ "resource": "" }
q30515
SitemapGenerator.generateSiteMap
train
protected function generateSiteMap($websiteUrl) { $urls = array(); foreach ($this->pageTreeCollection->getPages() as $pageTree) { $page = $pageTree->getPage(); if ( ! $page->getIsPublished()) { continue; } $seo = $pageTree->getSeo(); ...
php
{ "resource": "" }
q30516
WebSignature.getCompact
train
public function getCompact($key) { $headers = self::base64Encode(Parser::encode($this->headers)); $claim = self::base64Encode($this->claim); $signature = $this->getEncodedSignature($key); return $headers . '.' . $claim . '.' . $signature; }
php
{ "resource": "" }
q30517
WebSignature.getJson
train
public function getJson($key) { $signature = array(); $signature['protected'] = self::base64Encode(Parser::encode($this->headers)); $signature['payload'] = self::base64Encode($this->claim); $signature['signature'] = $this->getEncodedSignature($key); return Parser::encode($...
php
{ "resource": "" }
q30518
SeoManager.deleteSeoAttributesFromLanguage
train
public function deleteSeoAttributesFromLanguage($languageId, $pageId) { $alSeo = $this->seoRepository->fromPageAndLanguage($languageId, $pageId); // Occours when the attributes has been already removed if (null === $alSeo) return true; $this->set($alSeo); $result = $this->de...
php
{ "resource": "" }
q30519
SeoManager.add
train
protected function add(array $values) { $values = $this->dispatchBeforeOperationEvent( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeSeoAddingEvent', SeoEvents::BEFORE_ADD_SEO, $values, array( ...
php
{ "resource": "" }
q30520
SeoManager.edit
train
protected function edit(array $values = array()) { $values = $this->dispatchBeforeOperationEvent( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeSeoEditingEvent', SeoEvents::BEFORE_EDIT_SEO, $values, array( ...
php
{ "resource": "" }
q30521
Property.getFormId
train
public function getFormId() { // allowed are a-zA-Z0-9-_:. // no spaces $form = $this->getForm(); $formId = $form->getName(); if ($form instanceof FormCollectionInterface) { $formId .= '_' . $this->getEntityContainer()->getName(); } $formId .= '...
php
{ "resource": "" }
q30522
Property.getFormName
train
public function getFormName() { $form = $this->getForm(); $formName = $form->getName(); if ($form instanceof FormCollectionInterface) { $formName .= '[' . $this->getEntityContainer()->getName() . ']'; } $formName .= '[' . $this->getName() . ']'; return $...
php
{ "resource": "" }
q30523
Property.getFormValue
train
public function getFormValue() { $mapper = new PropertyMapper(); return $mapper->mapDataToForm($this->getEntityContainer()->getEntity(), $this->getName()); }
php
{ "resource": "" }
q30524
Property.getFormLabel
train
public function getFormLabel($domain=null) { $form = $this->getForm(); $translationDomain = !is_null($domain) ? $domain : 'forms'; $translator = $form->getTranslator(); $id = $form->getName(); if ($form instanceof FormCollectionInterface) { if (!is_int($this->get...
php
{ "resource": "" }
q30525
Google.createUrl
train
protected function createUrl($query) { $options = $this->getOptions(); $path = sprintf( 'http://translate.google.com/translate_tts?ie=%s&tl=%s&q=%s', $options->hasEncoding() ? $options->getEncoding() : 'UTF-8', $options->getLanguage(), urlencode($query...
php
{ "resource": "" }
q30526
SchemaBuilder.create
train
protected function create() { $fields = []; $keys = []; foreach ($this->getCurrentTable()->getFields() as $name => $field) { $fields[] = implode(' ', [ '`' . $field->getName() . '`', $field->getType() . '(' . $field->getLength() . ')', ...
php
{ "resource": "" }
q30527
TranslationUtil.translateLayout
train
public static function translateLayout(LayoutInterface $template, $locale, TranslatorInterface $translator = null) { if (null === $template->getTranslationDomain()) { $template = $template->getTranslation($locale); } elseif (null !== $translator) { static::injectTranslatorVal...
php
{ "resource": "" }
q30528
TranslationUtil.translateMail
train
public static function translateMail(MailInterface $template, $locale, TranslatorInterface $translator = null) { if (null === $template->getTranslationDomain()) { $template = $template->getTranslation($locale); } elseif (null !== $translator) { static::injectTranslatorValues(...
php
{ "resource": "" }
q30529
TranslationUtil.find
train
public static function find($template, $locale) { $locale = strtolower($locale); foreach ($template->getTranslations() as $translation) { if ($locale === strtolower($translation->getLocale())) { static::injectValue($template, $translation, 'label'); stati...
php
{ "resource": "" }
q30530
TranslationUtil.injectFile
train
public static function injectFile(TemplateInterface $template, TemplateTranslationInterface $translation): void { if ($template instanceof TemplateFileInterface && $translation instanceof TemplateFileInterface) { /** @var TemplateInterface $template */ /** @var TemplateTranslationInt...
php
{ "resource": "" }
q30531
TranslationUtil.injectValue
train
protected static function injectValue(TemplateInterface $template, TemplateTranslationInterface $translation, $field): void { $setter = 'set'.ucfirst($field); $getter = 'get'.ucfirst($field); $refTpl = new \ReflectionClass($template); $refTrans = new \ReflectionClass($translation); ...
php
{ "resource": "" }
q30532
TranslationUtil.injectTranslatorValues
train
protected static function injectTranslatorValues(TranslatorInterface $translator, TemplateInterface $template): void { static::injectTranslatorValue($translator, $template, 'label'); static::injectTranslatorValue($translator, $template, 'description'); static::injectTranslatorValue($translat...
php
{ "resource": "" }
q30533
TranslationUtil.injectTranslatorValue
train
protected static function injectTranslatorValue(TranslatorInterface $translator, TemplateInterface $template, $field): void { $setter = 'set'.ucfirst($field); $getter = 'get'.ucfirst($field); $refTpl = new \ReflectionClass($template); if ($refTpl->hasMethod($getter) && $refTpl->hasM...
php
{ "resource": "" }
q30534
UTF8.chr
train
public static function chr(int $codepoint): string { if ($codepoint <= 0x7F) { return \chr($codepoint); } if ($codepoint <= 0x7FF) { return \chr(0xC0 | $codepoint >> 6) . \chr(0x80 | $codepoint & 0x3F); } if ($codepoint <= 0xFFFF) { ...
php
{ "resource": "" }
q30535
UTF8.ord
train
public static function ord(string $char): int { $h = \ord($char[0]); if ($h <= 0x7F) { return $h; } if ($h < 0xC2) { throw new \InvalidArgumentException('Could not get unicode codepoint for character: "' . $char . '"'); } ...
php
{ "resource": "" }
q30536
ACL.makePublic
train
public static function makePublic() { $acl = new ACL(); $acl->addReferrer(self::READ, '*'); $acl->allowListings(); return $acl; }
php
{ "resource": "" }
q30537
ACL.newFromHeaders
train
public static function newFromHeaders($headers) { $acl = new ACL(); // READ rules. $rules = array(); if (!empty($headers[self::HEADER_READ])) { $read = $headers[self::HEADER_READ]; $rules = explode(',', $read); foreach ($rules as $rule) { $ruleArray = self::parseRule(self::REA...
php
{ "resource": "" }
q30538
ACL.addAccount
train
public function addAccount($perm, $account, $user = NULL) { $rule = array('account' => $account); if (!empty($user)) { $rule['user'] = $user; } $this->addRule($perm, $rule); return $this; }
php
{ "resource": "" }
q30539
ACL.headers
train
public function headers() { $headers = array(); $readers = array(); $writers = array(); // Create the rule strings. We need two copies, one for READ and // one for WRITE. foreach ($this->rules as $rule) { // We generate read and write rules separately so that the // generation logic...
php
{ "resource": "" }
q30540
ACL.ruleToString
train
protected function ruleToString($perm, $rule) { // Some rules only apply to READ. if (self::READ & $perm) { // Host rule. if (!empty($rule['host'])) { return '.r:' . $rule['host']; } // Listing rule. if (!empty($rule['rlistings'])) { return '.rlistings'; } ...
php
{ "resource": "" }
q30541
ACL.isPublic
train
public function isPublic() { $allowsAllHosts = FALSE; $allowsRListings = FALSE; foreach ($this->rules as $rule) { if (self::READ & $rule['mask']) { if (!empty($rule['rlistings'])) { $allowsRListings = TRUE; } elseif(!empty($rule['host']) && trim($rule['host']) == '*')...
php
{ "resource": "" }
q30542
WidgetManager.createDashDriver
train
protected function createDashDriver(string $name): Handlers\Dash { $config = $this->app->make('config')->get("orchestra/widget::dash.{$name}", []); return new Handlers\Dash($name, $config); }
php
{ "resource": "" }
q30543
WidgetManager.createMenuDriver
train
protected function createMenuDriver(string $name): Handlers\Menu { $config = $this->app->make('config')->get("orchestra/widget::menu.{$name}", []); return new Handlers\Menu($name, $config); }
php
{ "resource": "" }
q30544
WidgetManager.createPaneDriver
train
protected function createPaneDriver(string $name): Handlers\Pane { $config = $this->app->make('config')->get("orchestra/widget::pane.{$name}", []); return new Handlers\Pane($name, $config); }
php
{ "resource": "" }
q30545
WidgetManager.createPlaceholderDriver
train
protected function createPlaceholderDriver(string $name): Handlers\Placeholder { $config = $this->app->make('config')->get("orchestra/widget::placeholder.{$name}", []); return new Handlers\Placeholder($name, $config); }
php
{ "resource": "" }
q30546
WidgetManager.of
train
public function of($name, Closure $callback = null): Handler { if ($name instanceof Closure) { $callback = $name; $name = $this->getDefaultDriver(); } $instance = $this->make($name); if ($instance instanceof Handler && ! \is_null($callback)) { $c...
php
{ "resource": "" }
q30547
Index.consumer
train
public function consumer($url, $key, $secret) { Argument::i() //argument 1 must be a string ->test(1, 'string') //argument 2 must be a string ->test(2, 'string') //argument 3 must be a string ->test(3, 'string'); re...
php
{ "resource": "" }
q30548
Index.getHmacGetAccessToken
train
public function getHmacGetAccessToken( $url, $key, $secret, $token, $tokenSecret, array $query = array(), $realm = null, $verifier = null ) { //argument test Argument::i() //Argument 1 must be a string ->test(1, ...
php
{ "resource": "" }
q30549
Index.getHmacGetAuthorizationRequestToken
train
public function getHmacGetAuthorizationRequestToken( $url, $key, $secret, array $query = array(), $realm = null ) { //argument test Argument::i() //Argument 1 must be a string ->test(1, 'string') //Argument 2 must be a strin...
php
{ "resource": "" }
q30550
Validator.addValidationMapping
train
public function addValidationMapping(BaseValidatorBuilderInterface $builder, $dirs) { if (empty($dirs)) { return; } $finder = Finder::create() ->files() ->filter(function (\SplFileInfo $file) { return 1 === substr_count($file->getBasename(...
php
{ "resource": "" }
q30551
BlockManagersCollection.indexAt
train
public function indexAt($index) { return ($index >= 0 && $index <= $this->count() - 1) ? $this->blockManagers[$index] : null; }
php
{ "resource": "" }
q30552
BlockManagersCollection.getManagerInfoByBlockId
train
public function getManagerInfoByBlockId($idBlock) { foreach ($this->blockManagers as $index => $blockManager) { if ($blockManager->get()->getId() == $idBlock) { return array('index' => $index, 'manager' => $blockManager); } } return null; }
php
{ "resource": "" }
q30553
BlockManagersCollection.getBlockManager
train
public function getBlockManager($idBlock) { $info = $this->getManagerInfoByBlockId($idBlock); return (null !== $info) ? $info['manager'] : null; }
php
{ "resource": "" }
q30554
BlockManagersCollection.getBlockManagerIndex
train
public function getBlockManagerIndex($idBlock) { $info = $this->getManagerInfoByBlockId($idBlock); return (null !== $info) ? $info['index'] : null; }
php
{ "resource": "" }
q30555
BlockManagersCollection.toArray
train
public function toArray() { $result = array(); foreach ($this->blockManagers as $blockManager) { if (null !== $blockManager) { $result[] = $blockManager->toArray(); } } return $result; }
php
{ "resource": "" }
q30556
BlockManagersCollection.insertAt
train
public function insertAt(BlockManagerInterface $element, $at) { $elements = count($this->blockManagers); $leftPart = array_slice($this->blockManagers, 0 , $at); $rightPart = array_slice($this->blockManagers, $at , $elements); $this->blockManagers = array_merge($leftPart, array($ele...
php
{ "resource": "" }
q30557
BlockManagersCollection.removeAt
train
public function removeAt($at) { $elements = count($this->blockManagers) - 1; $leftPart = array_slice($this->blockManagers, 0 , $at); $rightPart = array_slice($this->blockManagers, $at + 1, $elements); $this->blockManagers = array_merge($leftPart, $rightPart); return array(...
php
{ "resource": "" }
q30558
Map.set
train
public function set(string $key, $element): self { $this->validate($element); $this->elements[$key] = $element; foreach ($this->indexes as $index) { $index->add($key, $element); } return $this; }
php
{ "resource": "" }
q30559
SetPermissionsCommand.execute
train
public function execute(Arguments $args, ConsoleIo $io) { foreach (Configure::read('WRITABLE_DIRS') as $path) { $this->folderChmod($io, $path); } return null; }
php
{ "resource": "" }
q30560
Forwarding.maybeForward
train
public static function maybeForward($answerId, $postId, $comment, $email, $topicId) { $toGlobal = get_field('feedback_forwarding', 'option'); $toLocal = get_field('feedback_forwarding', $postId); if (!is_array($toGlobal)) { $toGlobal = array(); } if (!is_array($...
php
{ "resource": "" }
q30561
Plugin.path
train
public static function path($plugin, $file = null, $check = false) { $plugin = parent::path($plugin); if (!$file) { return $plugin; } $path = $plugin . $file; if ($check && !is_readable($path)) { throw new MissingPluginException(__d('me_tools', 'Fil...
php
{ "resource": "" }
q30562
TemplateSection.rewriteImagesPathForProduction
train
protected function rewriteImagesPathForProduction($content) { $imagesSourcePath = $this->imagesSourcePath; $imagesTargetPath = $this->imagesTargetPath; return preg_replace_callback('/([\/]?)(' . str_replace('/', '\/', $imagesSourcePath) . ')/s', function ($matches) use ($imagesTargetPath) {...
php
{ "resource": "" }
q30563
TemplateSection.rewriteLinksForProduction
train
protected function rewriteLinksForProduction($content) { $urlManager = $this->urlManager; $content = preg_replace_callback('/(\<a[^\>]+href[="\s]+)([^"\s]+)?([^\>]+\>)/s', function ($matches) use ($urlManager) { $url = $matches[2]; if (preg_match('/route:([^"]+)/i', $url, $...
php
{ "resource": "" }
q30564
ServiceContainer.getInstantiator
train
public function getInstantiator(): Instantiator { if (is_null($this->instantiator)) { $this->setInstantiator(new Instantiator(null, $this)); } return $this->instantiator; }
php
{ "resource": "" }
q30565
ServiceContainer.setInstantiator
train
private function setInstantiator(Instantiator $instantiator) { $this->instantiator = $instantiator; $this->add(new Service($this->instantiator)); }
php
{ "resource": "" }
q30566
SettingsPage.addSection
train
public function addSection(Section $section) { $this->registry['sections'][] = $section; $this->currentSection = $section; return $this; }
php
{ "resource": "" }
q30567
SettingsPage.addField
train
public function addField(Field $field) { $field ->setSection($this->currentSection) ->setOptionName($this->registry['option_name']) ; if (isset($this->registry['field_values'][$field->getId()])) { $field->setValue($this->registry['field_values'][$field->g...
php
{ "resource": "" }
q30568
SettingsPage.render
train
public function render() { $reg = $this->registry; ?> <div class="wrap"> <h1><?php echo $reg['page_title']; ?></h1> <form action="options.php" method="post"> <?php settings_errors($reg['option_name']) ?> <?php settings_fields($reg['opti...
php
{ "resource": "" }
q30569
BorderedElement.render
train
public function render() { $text = parent::render(); $borderedText = BorderManager::buildBorder($text, $this->border); return $borderedText; }
php
{ "resource": "" }
q30570
Smokescreen.item
train
public function item($data, $transformer = null, $key = null) { $this->setResource(new Item($data, $transformer, $key)); return $this; }
php
{ "resource": "" }
q30571
Smokescreen.collection
train
public function collection($data, TransformerInterface $transformer = null, $key = null, callable $callback = null) { $this->setResource(new Collection($data, $transformer, $key)); if ($callback !== null) { $callback($this->resource); } return $this; }
php
{ "resource": "" }
q30572
Smokescreen.setTransformer
train
public function setTransformer($transformer = null) { if (!$this->resource) { throw new MissingResourceException('Resource must be specified before setting a transformer'); } $this->resource->setTransformer($transformer); return $this; }
php
{ "resource": "" }
q30573
Smokescreen.parseIncludes
train
public function parseIncludes($str) { $this->includes = $this->getIncludeParser()->parse(!empty($str) ? $str : ''); return $this; }
php
{ "resource": "" }
q30574
EventStoreTable.create
train
public function create(DynamoDbClient $client, string $tableName): void { try { $client->describeTable(['TableName' => $tableName]); return; } catch (DynamoDbException $e) { // table doesn't exist, create it below } try { $client->crea...
php
{ "resource": "" }
q30575
HandleCors.addCors
train
public function addCors(bool $isConsole = false) { /** * Don't add Cors if this is a console application. * Application might fail if this is a PHPUnit test */ if ($isConsole) return; /** * This is not a console application, let's add * Cors! */ header('Access-Control-Al...
php
{ "resource": "" }
q30576
eZPage.toXML
train
public function toXML() { $dom = new DOMDocument( '1.0', 'utf-8' ); $dom->formatOutput = true; $success = $dom->loadXML('<page />'); $pageNode = $dom->documentElement; foreach ( $this->attributes as $attrName => $attrValue ) { switch ( $attrName ) ...
php
{ "resource": "" }
q30577
eZPage.createFromXML
train
public static function createFromXML( $source ) { $newObj = new eZPage(); if ( $source ) { $dom = new DOMDocument( '1.0', 'utf-8' ); $success = $dom->loadXML( $source ); $root = $dom->documentElement; foreach ( $root->childNodes as $node ) ...
php
{ "resource": "" }
q30578
eZPage.getZone
train
public function getZone( $index ) { $zone = null; if( isset( $this->attributes['zones'][$index] ) ) $zone = $this->attributes['zones'][$index]; return $zone; }
php
{ "resource": "" }
q30579
eZPage.removeZones
train
public function removeZones() { foreach( $this->attributes['zones'] as $index => $zone ) { if ( $zone->toBeAdded() ) $this->removeZone( $index ); else $zone->setAttribute( 'action', 'remove' ); } }
php
{ "resource": "" }
q30580
eZPage.removeProcessed
train
public function removeProcessed() { if ( $this->hasAttribute( 'action' ) ) { unset( $this->attributes['action'] ); } if ( $this->getZoneCount() > 0 ) { foreach ( $this->attributes['zones'] as $index => $zone ) { if ( $zone-...
php
{ "resource": "" }
q30581
eZPage.sortZones
train
public function sortZones() { $ini = eZINI::instance('zone.ini'); $zones = $ini->variable( $this->attribute('zone_layout'), 'Zones' ); $sortedZones = array(); foreach( $zones as $zone ) { foreach( $this->attribute('zones') as $zoneObj ) { ...
php
{ "resource": "" }
q30582
Args.map
train
public function map($definition) { $fixed = preg_replace('/\s+/', ' ', $definition); if (empty($fixed)) { return; } $names = explode(' ', $fixed); $newArgs = []; foreach ($this->args as $key => $value) { if (!is_int($key) && in_array($...
php
{ "resource": "" }
q30583
DocController.actionGenerate
train
public function actionGenerate() { $versionList = MiscHelper::getAllVersions(); $versionList = array_combine($versionList, $versionList); $selected = Select::display('Select package', $versionList); $version = Select::getFirstValue($selected); ApiDocHelper::generate($version); Output::block('Success generat...
php
{ "resource": "" }
q30584
Container.getPath
train
function getPath() { $path = $this->getName(); if ($this->__nestLeft) $path = $this->__nestLeft->getPath().self::SEPARATOR.$path; return $path; }
php
{ "resource": "" }
q30585
Container.setImplementation
train
function setImplementation($nameOrAlias, $implement) { if ($this->has($nameOrAlias)) throw new \Exception( "Service ({$nameOrAlias}) is already exists;" ."Interface must define before service registration." ); if ( is_string($implement) && !(i...
php
{ "resource": "" }
q30586
Container.hasImplementation
train
function hasImplementation($nameOrAlias) { #! When Service Extend From Another Must Have Same Implementation Rules $nameOrAlias = $this->getExtended($nameOrAlias); $nameOrAlias = $this->_normalizeName($nameOrAlias); return ( isset($this->implementations[$nameOrAlias]) ...
php
{ "resource": "" }
q30587
Container.set
train
function set(iContainerService $service) { $name = $service->getName(); if ($name !== null && $this->has($name) && !$this->_attainCService($name)->isAllowOverride()) throw new \Exception( "A service by the name or alias ({$name}) already exists and cannot be overridden;"...
php
{ "resource": "" }
q30588
Container.has
train
function has($nameOrAlias) { if (!(strpos($nameOrAlias, self::SEPARATOR) !== false)) $nameOrAlias = $this->getExtended($nameOrAlias); # check if we have alias to nested service: if (strpos($nameOrAlias, self::SEPARATOR) !== false) { // shared alias for nested contain...
php
{ "resource": "" }
q30589
Container.getExtended
train
function getExtended($nameOrAlias) { while ($this->isExtendedService($nameOrAlias)) { $cAlias = $this->_normalizeName($nameOrAlias); $nameOrAlias = $this->aliases[$cAlias]; ## check if we have alias to nested service if (strpos($nameOrAlias, self::SEPARAT...
php
{ "resource": "" }
q30590
Container.extend
train
function extend($newName, $nameOrAlias) { $throw = false; if ($this->has($newName)) // New Name Alias exists as a Service or Alias // - Check has allow override? { if ($this->isExtendedService($newName)) // New Name is Alias; achieve extended service ...
php
{ "resource": "" }
q30591
Container.isExtendedService
train
function isExtendedService($alias) { $cAlias = $this->_normalizeName($alias); return isset($this->aliases[$cAlias]); }
php
{ "resource": "" }
q30592
Container.initializer
train
function initializer() { if ($this->initializer) return $this->initializer; // .. $initializer = new InitializerAggregate($this); # attach defaults: $initializer->addCallable(function($instance, $self) { if ($instance instanceof iServicesAware) ...
php
{ "resource": "" }
q30593
Container.nest
train
function nest(Container $container, $namespace = null) { // Use Container Namespace if not provided as argument ($namespace !== null) ?: $namespace = $container->getName(); if ($namespace === null || $namespace === '') throw new \InvalidArgumentException( 'Namesp...
php
{ "resource": "" }
q30594
Container.from
train
function from($namespacePath) { if ($namespacePath === '') # from recursion calls return $this; // .. $cNamespace = $this->_normalizeNamespace($namespacePath); if (false === strstr($cNamespace, self::SEPARATOR)) { ## recursion fallback here !! ...
php
{ "resource": "" }
q30595
Container._initializeServiceOrInstance
train
function _initializeServiceOrInstance($inService) { # Invoke Service Features: if ($inService instanceof iServiceFeatureDelegate) $inService->delegate($this); # initialize with all parent namespaces, from root parent to current last $container = $this; $initi...
php
{ "resource": "" }
q30596
Container._validateImplementation
train
protected function _validateImplementation($serviceName, $instance) { if (false === $implement = $this->hasImplementation($serviceName)) ## we have not defined implementation, nothing to do return; // .. $throw = true; if (interface_exists($implement)) ...
php
{ "resource": "" }
q30597
Container._attainCService
train
protected function _attainCService($name) { $name = $this->getExtended($name); $cName = $this->_normalizeName($name); $return = (isset($this->services[$cName])) ? $this->services[$cName] : false; // Aggregate Feature: if ($return === false) { ## Looking in Ag...
php
{ "resource": "" }
q30598
Mission.getMissionGames
train
public function getMissionGames($mission, $user) { $games = array(); $missionGames = $this->findGamesByMission($mission); foreach ($missionGames as $missionGame) { $entry = $this->checkExistingEntry($missionGame->getGame(), $user); $games[$missionGame->getGame()->getI...
php
{ "resource": "" }
q30599
File.fromArray
train
public static function fromArray(array $file): self { $url = $file['file_ext'] === 'zip' ? $file['large_file_url'] : $file['file_url']; return new self( $file['file_size'], $url, self::getFileTypeByExtension($file['file_ext']), ...
php
{ "resource": "" }