_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2500 | Reporter.on | train | public function on() : self
{
$this->handler->setErrorHandler();
$this->handler->setExceptionHandler();
$this->handler->setFatalHandler();
return $this;
} | php | {
"resource": ""
} |
q2501 | Driver.start | train | public function start($type = '*firefox', $startUrl = 'http://localhost')
{
if (null !== $this->sessionId) {
throw new Exception("Session already started");
}
$response = $this->doExecute('getNewBrowserSession', $type, $startUrl);
if (preg_match('/^OK,(.*)$/', $response... | php | {
"resource": ""
} |
q2502 | Driver.getString | train | public function getString($command, $target = null, $value = null)
{
$result = $this->doExecute($command, $target, $value);
if (!preg_match('/^OK,/', $result)) {
throw new Exception("Unexpected response from Selenium server : ".$result);
}
return strlen($result) > 3 ? s... | php | {
"resource": ""
} |
q2503 | Driver.getStringArray | train | public function getStringArray($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
$results = preg_split('/(?<!\\\),/', $string);
foreach ($results as &$result) {
$result = str_replace('\,', ',', $result);
}
return $... | php | {
"resource": ""
} |
q2504 | Driver.getNumber | train | public function getNumber($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return (int) $string;
} | php | {
"resource": ""
} |
q2505 | Driver.getBoolean | train | public function getBoolean($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return $string == 'true';
} | php | {
"resource": ""
} |
q2506 | Driver.stop | train | public function stop()
{
if (null === $this->sessionId) {
throw new Exception("Session not started");
}
$this->doExecute('testComplete');
$this->sessionId = null;
} | php | {
"resource": ""
} |
q2507 | Driver.doExecute | train | protected function doExecute($command, $target = null, $value = null)
{
$postFields = array();
$query = array('cmd' => $command);
if ($target !== null) {
$postFields[1] = $target;
}
if ($value !== null) {
$postFields[2] = $value;
}
i... | php | {
"resource": ""
} |
q2508 | StacktraceFormatterTrait.unpackThrowables | train | private function unpackThrowables($throwable)
{
if (!$throwable instanceof Throwable) {
return [];
}
$throwables = [$throwable];
while ($throwable = $throwable->getPrevious()) {
$throwables[] = $throwable;
}
return $throwables;
} | php | {
"resource": ""
} |
q2509 | RenderViewHelper.renderStatic | train | public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var FieldViewHelperService $fieldService */
$fieldService = Core::instantiate(FieldViewHelperService::class);
if (false === $fieldService->fieldContextEx... | php | {
"resource": ""
} |
q2510 | ExceptionHandler.handle | train | public function handle($throwable)
{
if ($throwable instanceof Exception) {
$response = $this->handler->handleException($this->defaultRequest, $this->defaultResponse, $throwable);
} elseif ($throwable instanceof Throwable) {
$response = $this->handler->handleThrowable($this->... | php | {
"resource": ""
} |
q2511 | FieldViewHelper.storeViewDataLegacy | train | protected function storeViewDataLegacy()
{
$originalArguments = [];
$variableProvider = $this->getVariableProvider();
foreach (self::$reservedVariablesNames as $key) {
if ($variableProvider->exists($key)) {
$originalArguments[$key] = $variableProvider->get($key)... | php | {
"resource": ""
} |
q2512 | FieldViewHelper.injectFieldInService | train | protected function injectFieldInService($fieldName)
{
$formObject = $this->formService->getFormObject();
$formConfiguration = $formObject->getConfiguration();
if (false === is_string($fieldName)) {
throw InvalidArgumentTypeException::fieldViewHelperInvalidTypeNameArgument();
... | php | {
"resource": ""
} |
q2513 | FieldViewHelper.getLayout | train | protected function getLayout(View $viewConfiguration)
{
$layout = $this->arguments['layout'];
if (false === is_string($layout)) {
throw InvalidArgumentTypeException::invalidTypeNameArgumentFieldViewHelper($layout);
}
list($layoutName, $templateName) = GeneralUtility::tr... | php | {
"resource": ""
} |
q2514 | FieldViewHelper.getTemplateArguments | train | protected function getTemplateArguments()
{
$templateArguments = $this->arguments['arguments'] ?: [];
ArrayUtility::mergeRecursiveWithOverrule($templateArguments, $this->fieldService->getFieldOptions());
return $templateArguments;
} | php | {
"resource": ""
} |
q2515 | Convert.valueToBytes | train | public static function valueToBytes($value): int
{
if (is_int($value)) {
return $value;
}
$value = trim($value);
// Native PHP check for digits in string
if (ctype_digit(ltrim($value, '-'))) {
return (int)$value;
}
$signed = (substr(... | php | {
"resource": ""
} |
q2516 | Convert.objectToArray | train | public static function objectToArray($source): array
{
$result = [];
if (is_array($source)) {
return $source;
}
if (!is_object($source)) {
return $result;
}
$json = json_encode($source);
if ($json === false) {
return $res... | php | {
"resource": ""
} |
q2517 | Convert.dataToJson | train | public static function dataToJson(string $data, bool $lint = false): stdClass
{
if ($lint) {
$linter = new JsonParser();
$linter->parse($data);
}
$data = json_decode($data);
if ($data === null) {
throw new InvalidArgumentException("Failed to decod... | php | {
"resource": ""
} |
q2518 | URI.getQueryParam | train | public function getQueryParam(UriInterface $uri, $param)
{
if (!$query = $uri->getQuery()) {
return null;
}
parse_str($query, $params);
if (!array_key_exists($param, $params)) {
return null;
}
return $params[$param];
} | php | {
"resource": ""
} |
q2519 | URI.uriFor | train | public function uriFor($route, array $params = [], array $query = [])
{
if (!$route) {
return '';
}
return $this->router->relativePathFor($route, $params, $query);
} | php | {
"resource": ""
} |
q2520 | URI.absoluteURIFor | train | public function absoluteURIFor(UriInterface $uri, $route, array $params = [], array $query = [])
{
$path = $this->uriFor($route, $params);
return (string) $uri
->withUserInfo('')
->withPath($path)
->withQuery(http_build_query($query))
->withFragment('... | php | {
"resource": ""
} |
q2521 | FormBuilder.getTypeObject | train | private function getTypeObject($type, $args)
{
/* @var AbstractType $object */
if ($type instanceof AbstractType) {
$object = $type;
} else {
$class = $this->getTypeClass($type);
if (!\class_exists($class)) {
$class = TextType::class;
... | php | {
"resource": ""
} |
q2522 | BehavioursManager.applyBehaviourOnFormInstance | train | public function applyBehaviourOnFormInstance(FormObject $formObject)
{
if ($formObject->hasForm()) {
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $fieldName => $field) {
if (ObjectAccess::isPropertyGettable($formIns... | php | {
"resource": ""
} |
q2523 | ConditionFactory.registerCondition | train | public function registerCondition($name, $className)
{
if (false === is_string($name)) {
throw InvalidArgumentTypeException::conditionNameNotString($name);
}
if (false === class_exists($className)) {
throw ClassNotFoundException::conditionClassNameNotFound($name, $cl... | php | {
"resource": ""
} |
q2524 | ConditionFactory.registerDefaultConditions | train | public function registerDefaultConditions()
{
if (false === $this->defaultConditionsWereRegistered) {
$this->defaultConditionsWereRegistered = true;
$this->registerCondition(
FieldHasValueCondition::CONDITION_NAME,
FieldHasValueCondition::class
... | php | {
"resource": ""
} |
q2525 | TypoScriptService.getFormConfiguration | train | public function getFormConfiguration($formClassName)
{
$formzConfiguration = $this->getExtensionConfiguration();
return (isset($formzConfiguration['forms'][$formClassName]))
? $formzConfiguration['forms'][$formClassName]
: [];
} | php | {
"resource": ""
} |
q2526 | TypoScriptService.getExtensionConfiguration | train | protected function getExtensionConfiguration()
{
$cacheInstance = CacheService::get()->getCacheInstance();
$hash = $this->getContextHash();
if ($cacheInstance->has($hash)) {
$result = $cacheInstance->get($hash);
} else {
$result = $this->getFullConfiguration(... | php | {
"resource": ""
} |
q2527 | TypoScriptService.getFullConfiguration | train | protected function getFullConfiguration()
{
$contextHash = $this->getContextHash();
if (false === array_key_exists($contextHash, $this->configuration)) {
$typoScriptArray = ($this->environmentService->isEnvironmentInFrontendMode())
? $this->getFrontendTypoScriptConfigura... | php | {
"resource": ""
} |
q2528 | Generator.generate | train | public function generate(
ContainerConfiguration $config,
ConfigCache $dump
): ContainerInterface {
$this->compiler->compile($config, $dump, $this);
return $this->loadContainer($config, $dump);
} | php | {
"resource": ""
} |
q2529 | HtmlToJson.toJson | train | public function toJson($html)
{
// Strip white space between tags to prevent creation of empty #text nodes
$html = preg_replace('~>\s+<~', '><', $html);
$document = new \DOMDocument();
// Load UTF-8 HTML hack (from http://bit.ly/pVDyCt)
$document->loadHTML('<?xml encoding="U... | php | {
"resource": ""
} |
q2530 | HtmlToJson.convert | train | private function convert(\DOMElement $node)
{
foreach ($this->converters as $converter) {
if ($converter->matches($node)) {
return $converter->toJson($node);
}
}
} | php | {
"resource": ""
} |
q2531 | AbstractActivation.getConditions | train | public function getConditions()
{
$conditionList = $this->withFirstParent(
Form::class,
function (Form $formConfiguration) {
return $formConfiguration->getConditionList();
}
);
$conditionList = ($conditionList) ?: [];
ArrayUtility:... | php | {
"resource": ""
} |
q2532 | AbstractActivation.getCondition | train | public function getCondition($name)
{
if (false === $this->hasCondition($name)) {
throw EntryNotFoundException::activationConditionNotFound($name);
}
$items = $this->getConditions();
return $items[$name];
} | php | {
"resource": ""
} |
q2533 | FormService.getFormWithErrors | train | public static function getFormWithErrors($formClassName)
{
GeneralUtility::logDeprecatedFunction();
return (isset(self::$formWithErrors[$formClassName]))
? self::$formWithErrors[$formClassName]
: null;
} | php | {
"resource": ""
} |
q2534 | ConditionParser.getNodeRecursive | train | protected function getNodeRecursive()
{
while (false === empty($this->scope->getExpression())) {
$currentExpression = $this->scope->getExpression();
$this->processToken($currentExpression[0]);
$this->processLogicalAndNode();
}
$this->processLastLogicalOpe... | php | {
"resource": ""
} |
q2535 | ConditionParser.processToken | train | protected function processToken($token)
{
switch ($token) {
case ')':
$this->processTokenClosingParenthesis();
break;
case '(':
$this->processTokenOpeningParenthesis();
break;
case self::LOGICAL_OR:
... | php | {
"resource": ""
} |
q2536 | ConditionParser.processTokenOpeningParenthesis | train | protected function processTokenOpeningParenthesis()
{
$groupNode = $this->getGroupNode($this->scope->getExpression());
$scopeSave = $this->scope;
$expression = array_slice($scopeSave->getExpression(), count($groupNode) + 2);
$scopeSave->setExpression($expression);
$this->sc... | php | {
"resource": ""
} |
q2537 | ConditionParser.processTokenLogicalOperator | train | protected function processTokenLogicalOperator($operator)
{
if (null === $this->scope->getNode()) {
$this->addError('Logical operator must be preceded by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_PRECEDED);
} else {
if (self::LOGICAL_OR === $operator) {
... | php | {
"resource": ""
} |
q2538 | ConditionParser.processTokenCondition | train | protected function processTokenCondition($condition)
{
if (false === $this->condition->hasCondition($condition)) {
$this->addError('The condition "' . $condition . '" does not exist.', self::ERROR_CODE_CONDITION_NOT_FOUND);
} else {
$node = new ConditionNode($condition, $this... | php | {
"resource": ""
} |
q2539 | ConditionParser.processLogicalAndNode | train | protected function processLogicalAndNode()
{
if (null !== $this->scope->getCurrentLeftNode()
&& null !== $this->scope->getNode()
&& null !== $this->scope->getCurrentOperator()
) {
$node = new BooleanNode($this->scope->getCurrentLeftNode(), $this->scope->getNode(),... | php | {
"resource": ""
} |
q2540 | ConditionParser.processLastLogicalOperatorNode | train | protected function processLastLogicalOperatorNode()
{
if (null !== $this->scope->getCurrentLeftNode()) {
$this->addError('Logical operator must be followed by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_FOLLOWED);
} elseif (null !== $this->scope->getLastOrNode()) {
... | php | {
"resource": ""
} |
q2541 | ConditionParser.getGroupNodeClosingIndex | train | protected function getGroupNodeClosingIndex(array $expression)
{
$parenthesis = 1;
$index = 0;
while ($parenthesis > 0) {
$index++;
if ($index > count($expression)) {
$this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENT... | php | {
"resource": ""
} |
q2542 | Salt.getSalt | train | public static function getSalt(): string
{
$result = '';
try {
$result = static::readSaltFromFile();
} catch (InvalidArgumentException $e) {
Log::warning("Failed to read salt from file");
}
if ($result) {
return $result;
}
... | php | {
"resource": ""
} |
q2543 | Salt.readSaltFromFile | train | protected static function readSaltFromFile(): string
{
Utility::validatePath(static::$saltFile);
$result = file_get_contents(static::$saltFile);
$result = $result ?: '';
static::validateSalt($result);
return $result;
} | php | {
"resource": ""
} |
q2544 | Salt.writeSaltToFile | train | protected static function writeSaltToFile(string $salt): void
{
static::validateSalt($salt);
$result = @file_put_contents(static::$saltFile, $salt);
if (($result === false) || ($result <> strlen($salt))) {
throw new InvalidArgumentException("Failed to write salt to file [" . sta... | php | {
"resource": ""
} |
q2545 | Salt.validateSalt | train | protected static function validateSalt(string $salt): void
{
if (!ctype_print($salt)) {
throw new InvalidArgumentException("Salt is not a printable string");
}
static::validateSaltMinLength();
$saltLength = strlen($salt);
if ($saltLength < static::$saltMinLength... | php | {
"resource": ""
} |
q2546 | Salt.generateSalt | train | protected static function generateSalt(): string
{
$result = '';
static::validateSaltMinLength();
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$poolSize = strlen($pool);
for ($i = 0; $i < static::$saltMinLength; $i++) {
$result .= $p... | php | {
"resource": ""
} |
q2547 | Client.getBrowser | train | public function getBrowser($startPage, $type = '*firefox')
{
$url = 'http://'.$this->host.':'.$this->port.'/selenium-server/driver/';
$driver = new Driver($url, $this->timeout);
$class = $this->browserClass;
return new $class($driver, $startPage, $type);
} | php | {
"resource": ""
} |
q2548 | MySQL.describeTable | train | public function describeTable($table)
{
if (!$this->connection->expr('show tables like []', [$table])->get()) {
return []; // no such table
}
$result = [];
foreach ($this->connection->expr('describe {}', [$table]) as $row) {
$row2 = [];
$row2['na... | php | {
"resource": ""
} |
q2549 | FormObjectHash.getHash | train | public function getHash()
{
if (null === $this->hash) {
$this->hash = $this->calculateHash();
}
return $this->hash;
} | php | {
"resource": ""
} |
q2550 | ErrorHandler.register | train | public function register($handledErrors = E_ALL)
{
$errHandler = [$this, 'handleError'];
$exHandler = [$this, 'handleException'];
$handledErrors = is_int($handledErrors) ? $handledErrors : E_ALL;
set_error_handler($errHandler, $handledErrors);
set_exception_handler($exHandl... | php | {
"resource": ""
} |
q2551 | ErrorHandler.registerShutdown | train | public function registerShutdown()
{
if (self::$reservedMemory === null) {
self::$reservedMemory = str_repeat('x', 10240);
register_shutdown_function(__CLASS__ . '::handleFatalError');
}
self::$exceptionHandler = [$this, 'handleException'];
return $this;
... | php | {
"resource": ""
} |
q2552 | ConditionProcessorFactory.fetchProcessorInstanceFromCache | train | protected function fetchProcessorInstanceFromCache($cacheIdentifier, FormObject $formObject)
{
$cacheInstance = CacheService::get()->getCacheInstance();
/** @var ConditionProcessor $instance */
if ($cacheInstance->has($cacheIdentifier)) {
$instance = $cacheInstance->get($cacheId... | php | {
"resource": ""
} |
q2553 | GoogleRecaptcha.verify | train | public function verify($response)
{
$result = $this->getVerificationResult($response);
if ($result['success']) {
return true;
}
if (!empty($result['error-codes'])) {
$this->errors = $result['error-codes'];
}
return false;
} | php | {
"resource": ""
} |
q2554 | GoogleRecaptcha.getScriptSrc | train | protected function getScriptSrc($onloadCallbackName)
{
$url = static::SCRIPT_URL;
$queryArgs = [];
\parse_str(\parse_url($url, PHP_URL_QUERY), $queryArgs);
$queryArgs['onload'] = $onloadCallbackName;
$queryArgs['render'] = 'explicit';
$url = \sprintf('%s?%s', \strt... | php | {
"resource": ""
} |
q2555 | NegotiatingContentHandler.getContentTypeHandler | train | private function getContentTypeHandler(ServerRequestInterface $request)
{
$acceptHeader = $request->getHeaderLine('Accept');
$acceptedTypes = explode(',', $acceptHeader);
foreach ($this->handlers as $contentType => $handler) {
if ($this->doesTypeMatch($acceptedTypes, $contentTyp... | php | {
"resource": ""
} |
q2556 | FootprintBehavior.beforeSave | train | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
if (! is_callable($this->getConfig('callback'))) {
return;
}
$user = call_user_func($this->getConfig('callback'));
if (empty($user['id'])) {
return;
}
... | php | {
"resource": ""
} |
q2557 | BuilderAbstract.build | train | public function build(InputSettings $settings)
{
$this->settings = $settings;
$this->setElement();
$this->setValidator();
$this->setLabel();
$this->setDefault();
$this->setAttributes();
$this->setData();
$this->setAdditionalOptions();
return ... | php | {
"resource": ""
} |
q2558 | BuilderAbstract.initElement | train | public function initElement()
{
if(is_null($this->settings)) {
$this->settings = new InputSettings();
}
return $this->build($this->settings);
} | php | {
"resource": ""
} |
q2559 | BuilderAbstract.setLabel | train | public function setLabel()
{
if($this->settings->getValue(InputSettings::LABEL_PARAM)) {
$this->element->setLabel($this->settings->getValue(InputSettings::LABEL_PARAM));
} else {
$this->element->setLabel(preg_replace('/.*\\\/', '', get_class($this)));
}
} | php | {
"resource": ""
} |
q2560 | BuilderAbstract.setDefault | train | public function setDefault()
{
if($this->settings->getValue(InputSettings::DEFAULTS_PARAM)) {
$this->element->setDefault($this->settings->getValue(InputSettings::DEFAULTS_PARAM));
}
} | php | {
"resource": ""
} |
q2561 | BuilderAbstract.setAttributes | train | public function setAttributes()
{
if($this->settings->getValue(InputSettings::PLACEHOLDER_PARAM)) {
$this->element->setAttribute('placeholder', $this->settings->getValue(InputSettings::PLACEHOLDER_PARAM));
}
} | php | {
"resource": ""
} |
q2562 | DoctrineWriter.getNewInstance | train | protected function getNewInstance()
{
$className = $this->objectMetadata->getName();
if (class_exists($className) === false) {
throw new \RuntimeException('Unable to create new instance of ' . $className);
}
return new $className;
} | php | {
"resource": ""
} |
q2563 | DoctrineWriter.setValue | train | protected function setValue($object, $value, $setter)
{
if (method_exists($object, $setter)) {
$object->$setter($value);
}
} | php | {
"resource": ""
} |
q2564 | AssetHandlerFactory.getAssetHandler | train | public function getAssetHandler($className)
{
if (false === array_key_exists($className, $this->instances)) {
if (false === class_exists($className)) {
throw ClassNotFoundException::wrongAssetHandlerClassName($className);
}
$instance = GeneralUtility::mak... | php | {
"resource": ""
} |
q2565 | FormInitializationJavaScriptAssetHandler.getFormInitializationJavaScriptCode | train | public function getFormInitializationJavaScriptCode()
{
$formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
$formConfigurationJson = $this->handleFormConfiguration($this->getFormConfiguration());
$javaScriptCode = <<<JS
(function() {
Fz.Form.register($formName, ... | php | {
"resource": ""
} |
q2566 | FormInitializationJavaScriptAssetHandler.getFormConfiguration | train | protected function getFormConfiguration()
{
$formConfigurationArray = $this->getFormObject()->getConfiguration()->toArray();
$this->removeFieldsValidationConfiguration($formConfigurationArray)
->addClassNameProperty($formConfigurationArray);
return ArrayService::get()->arrayToJa... | php | {
"resource": ""
} |
q2567 | FormInitializationJavaScriptAssetHandler.removeFieldsValidationConfiguration | train | protected function removeFieldsValidationConfiguration(array &$formConfiguration)
{
foreach ($formConfiguration['fields'] as $fieldName => $fieldConfiguration) {
if (true === isset($fieldConfiguration['validation'])) {
unset($fieldConfiguration['validation']);
uns... | php | {
"resource": ""
} |
q2568 | FormzLocalizationJavaScriptAssetHandler.getJavaScriptCode | train | public function getJavaScriptCode()
{
$realTranslations = [];
$translationsBinding = [];
foreach ($this->translations as $key => $value) {
$hash = HashService::get()->getHash($value);
$realTranslations[$hash] = $value;
$translationsBinding[$key] = $hash;
... | php | {
"resource": ""
} |
q2569 | FormzLocalizationJavaScriptAssetHandler.getTranslationKeysForFieldValidation | train | public function getTranslationKeysForFieldValidation(Field $field, $validationName)
{
$result = [];
if (true === $field->hasValidation($validationName)) {
$key = $field->getName() . '-' . $validationName;
$this->storeTranslationsForFieldValidation($field);
$res... | php | {
"resource": ""
} |
q2570 | FormzLocalizationJavaScriptAssetHandler.injectTranslationsForFormFieldsValidation | train | public function injectTranslationsForFormFieldsValidation()
{
$formConfiguration = $this->getFormObject()->getConfiguration();
foreach ($formConfiguration->getFields() as $field) {
$this->storeTranslationsForFieldValidation($field);
}
return $this;
} | php | {
"resource": ""
} |
q2571 | FormzLocalizationJavaScriptAssetHandler.storeTranslationsForFieldValidation | train | protected function storeTranslationsForFieldValidation(Field $field)
{
if (false === $this->translationsForFieldValidationWereInjected($field)) {
$fieldName = $field->getName();
foreach ($field->getValidation() as $validationName => $validation) {
$messages = Validat... | php | {
"resource": ""
} |
q2572 | FormzLocalizationJavaScriptAssetHandler.translationsForFieldValidationWereInjected | train | protected function translationsForFieldValidationWereInjected(Field $field)
{
$key = $this->getFormObject()->getClassName() . '-' . $field->getName();
return true === isset($this->injectedTranslationKeysForFieldValidation[$key]);
} | php | {
"resource": ""
} |
q2573 | Configuration.getConfigurationObjectServices | train | public static function getConfigurationObjectServices()
{
return ServiceFactory::getInstance()
->attach(ServiceInterface::SERVICE_CACHE)
->with(ServiceInterface::SERVICE_CACHE)
->setOption(CacheService::OPTION_CACHE_NAME, InternalCacheService::CONFIGURATION_OBJECT_CACHE_I... | php | {
"resource": ""
} |
q2574 | Configuration.addForm | train | public function addForm(FormObject $form)
{
if (true === $this->hasForm($form->getClassName(), $form->getName())) {
throw DuplicateEntryException::formWasAlreadyRegistered($form);
}
$form->getConfiguration()->setParents([$this]);
$this->forms[$form->getClassName()][$for... | php | {
"resource": ""
} |
q2575 | Configuration.calculateHash | train | public function calculateHash()
{
$fullArray = $this->toArray();
$configurationArray = [
'view' => $fullArray['view'],
'settings' => $fullArray['settings']
];
$this->hash = HashService::get()->getHash(serialize($configurationArray));
} | php | {
"resource": ""
} |
q2576 | MethodBuilder.buildCode | train | public function buildCode()
{
$code = '';
if ($this->documentation) {
$code .= ' /**'."\n";
$code .= ' * '.str_replace("\n", "\n * ", wordwrap($this->documentation, 73))."\n";
$code .= ' */'."\n";
}
$code .= ' public function '.... | php | {
"resource": ""
} |
q2577 | Taxonomy.createVocabulary | train | public function createVocabulary($name) {
if ($this->vocabulary->where('name', $name)->count()) {
throw new Exceptions\VocabularyExistsException();
}
return $this->vocabulary->create(['name' => $name]);
} | php | {
"resource": ""
} |
q2578 | Taxonomy.getVocabularyByNameAsArray | train | public function getVocabularyByNameAsArray($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first();
if (!is_null($vocabulary)) {
return $vocabulary->terms->pluck('name', 'id')->toArray();
}
return [];
} | php | {
"resource": ""
} |
q2579 | Taxonomy.getVocabularyByNameOptionsArray | train | public function getVocabularyByNameOptionsArray($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first();
if (is_null($vocabulary)) {
return [];
}
$parents = $this->term->whereParent(0)
->whereVocabularyId($vocabulary->id)
->orderBy('weight', 'ASC')
->get();
... | php | {
"resource": ""
} |
q2580 | Taxonomy.recurse_children | train | private function recurse_children($parent, &$options, $depth = 1) {
$parent->childrens->map(function($child) use (&$options, $depth) {
$options[$child->id] = str_repeat('-', $depth) .' '. $child->name;
if ($child->childrens) {
$this->recurse_children($child, $options, $depth+1);
}
});... | php | {
"resource": ""
} |
q2581 | Taxonomy.deleteVocabularyByName | train | public function deleteVocabularyByName($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first();
if (!is_null($vocabulary)) {
return $vocabulary->delete();
}
return FALSE;
} | php | {
"resource": ""
} |
q2582 | Taxonomy.createTerm | train | public function createTerm($vid, $name, $parent = 0, $weight = 0) {
$vocabulary = $this->vocabulary->findOrFail($vid);
$term = [
'name' => $name,
'vocabulary_id' => $vid,
'parent' => $parent,
'weight' => $weight,
];
return $this->term->create($term);
} | php | {
"resource": ""
} |
q2583 | ConditionIsValidValidator.isValid | train | public function isValid($condition)
{
$conditionTree = ConditionParser::get()
->parse($condition);
if (true === $conditionTree->getValidationResult()->hasErrors()) {
$errorMessage = $this->translateErrorMessage(
'validator.form.condition_is_valid.error',
... | php | {
"resource": ""
} |
q2584 | InjectorServiceProvider.alias | train | protected function alias($aliasKey, $serviceKey)
{
// Bound as a factory to ALWAYS pass through to underlying definition.
$this->bindFactory(
$aliasKey,
function (Container $app) use ($serviceKey) {
return $app[$serviceKey];
}
);
} | php | {
"resource": ""
} |
q2585 | InjectorServiceProvider.autoBind | train | protected function autoBind($className, callable $parameterFactory = null)
{
$this->bind(
$className,
$this->closureFactory->createAutoWireClosure($className, $parameterFactory)
);
} | php | {
"resource": ""
} |
q2586 | InjectorServiceProvider.autoBindFactory | train | protected function autoBindFactory($className, callable $parameterFactory = null)
{
$this->bindFactory(
$className,
$this->closureFactory->createAutoWireClosure($className, $parameterFactory)
);
} | php | {
"resource": ""
} |
q2587 | Injector.create | train | public function create($className, $parameters = [])
{
$reflectionClass = new \ReflectionClass($className);
if (!$reflectionClass->hasMethod("__construct")) {
//This class doesn't have a constructor
return $reflectionClass->newInstanceWithoutConstructor();
}
i... | php | {
"resource": ""
} |
q2588 | Injector.canAutoCreate | train | public function canAutoCreate($className)
{
foreach ($this->autoCreateWhiteList as $regex) {
if (preg_match($regex, $className)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q2589 | Injector.buildParameterArray | train | private function buildParameterArray($methodSignature, $providedParameters)
{
$parameters = [];
foreach ($methodSignature as $position => $parameterData) {
if (!isset($parameterData['variadic'])) {
$parameters[$position] = $this->resolveParameter($position, $parameterData... | php | {
"resource": ""
} |
q2590 | ParameterInspector.getSignatureByReflectionClass | train | public function getSignatureByReflectionClass(\ReflectionClass $reflectionClass, $methodName)
{
$className = $reflectionClass->getName();
return $this->getMethodSignature($className, $methodName, $reflectionClass);
} | php | {
"resource": ""
} |
q2591 | BindingClosureFactory.createAutoWireClosure | train | public function createAutoWireClosure($className, callable $parameterFactory = null)
{
return function (Container $app) use ($className, $parameterFactory) {
$parameters = $parameterFactory ? $parameterFactory($app) : [];
return $this->injector->create($className, $parameters);
... | php | {
"resource": ""
} |
q2592 | BindingClosureFactory.createProxy | train | private function createProxy($className, callable $serviceFactory, Container $app)
{
return $this->proxyFactory->createProxy(
$className,
function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) use (
$className,
$serviceFactory,
... | php | {
"resource": ""
} |
q2593 | Packages.classmap | train | public function classmap()
{
$path = $this->composerPath . $this->classmapName;
$i = 0;
if (is_file($path)) {
$data = include $path;
foreach ($data as $key => $value) {
if (false === empty($value)) {
$this->libs[addcslashes($key, ... | php | {
"resource": ""
} |
q2594 | Packages.psr0 | train | public function psr0()
{
$i = $this->load($this->composerPath . $this->psrZeroName);
if ($i !== false) {
$this->log[] = 'Imported ' . $i . ' classes from psr0';
return $i;
}
$this->log[] = 'Warn: psr0 not found';
return false;
} | php | {
"resource": ""
} |
q2595 | Packages.psr4 | train | public function psr4()
{
$i = $this->load($this->composerPath . $this->psrFourName);
if ($i !== false) {
$this->log[] = 'Imported ' . $i . ' classes from psr4';
return $i;
}
$this->log[] = 'Warn: psr4 not found';
return false;
} | php | {
"resource": ""
} |
q2596 | Packages.save | train | public function save($path)
{
if (count($this->libs) === 0) {
return false;
}
$handle = fopen($path, 'w');
if ($handle === false) {
throw new \InvalidArgumentException('This path is not writabled: ' . $path);
}
$first = true;
$eol = ... | php | {
"resource": ""
} |
q2597 | Packages.version | train | public static function version($name)
{
$file = INPHINIT_ROOT . 'composer.lock';
$data = is_file($file) ? json_decode(file_get_contents($file)) : false;
if (empty($data->packages)) {
return false;
}
$version = false;
foreach ($data->packages as $package... | php | {
"resource": ""
} |
q2598 | ObjectArrayStorage.get | train | public function get($object) : array
{
$values = $this->storage->get($object);
return ($values === null) ? [] : $values;
} | php | {
"resource": ""
} |
q2599 | ObjectArrayStorage.add | train | public function add($object, $value) : void
{
$values = $this->get($object);
$values[] = $value;
$this->storage->set($object, $values);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.