_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q263300
GestPayCryptWS.getDecParams
test
private function getDecParams() { // Parametri obbligatori $params = array( 'shopLogin' => $this->getShopLogin(), 'CryptedString' => $this->getEncryptedString(), ); return array_merge($params, $this->getOptParams()); }
php
{ "resource": "" }
q263301
UpdateProcess.saveDynamicData
test
private function saveDynamicData($entity, $data) { $fields = new DynamicFields($entity); $fields->init($data); $fields->save(); }
php
{ "resource": "" }
q263302
File.valid
test
public function valid() { $bResult = false; if ($this->getOption('required') == 'true') { $value = $this->getValue(); if (empty($value)) { $this->isValid = false; } else { $bResult = true; } } else { ...
php
{ "resource": "" }
q263303
File.save
test
public function save() { if (isset($this->file)) { $fileName = $this->entityId . '_' . $this->fieldId . '.' . $this->file->getClientOriginalExtension(); $this->value = $fileName; $this->file->move(public_path() . config('asgard.dynamicfield.config.files-path'), $fileName)...
php
{ "resource": "" }
q263304
DynamicFields.init
test
public function init($default = null) { $this->request = $default; $locale = $this->locale; $entityItem = $this->entity; $type = $this->type; if (isset($locale)) { $entity = new Entity($entityItem->id, $entityItem->template, $locale, $type); $entity->...
php
{ "resource": "" }
q263305
DynamicFields.renderFields
test
public function renderFields($locale) { $entity = $this->entities[$locale]; if (isset($this->request)) { $entity->valid(); } $html = $entity->render(); return $html; }
php
{ "resource": "" }
q263306
DynamicFields.getFieldValue
test
public function getFieldValue($fieldName, $locale = 'en') { $strValue = ''; $entity = $this->entities[$locale]; $values = $entity->values(); if (count($values)) { $keys = array_keys($values); if (in_array($fieldName, $keys)) { $strValue = $valu...
php
{ "resource": "" }
q263307
DynamicFields.getFieldValues
test
public function getFieldValues($locale = 'en') { $entity = $this->entities[$locale]; $values = $entity->values(); return $values; }
php
{ "resource": "" }
q263308
DynamicFields.valid
test
public function valid() { $isValid = true; foreach ($this->entities as $entity) { $isValid = $entity->valid(); if (!$isValid) { break; } } return $isValid; }
php
{ "resource": "" }
q263309
DynamicFields.save
test
public function save() { $isSave = true; foreach ($this->entities as $entity) { $isSave = $entity->save(); if (!$isSave) { break; } } return $isSave; }
php
{ "resource": "" }
q263310
DynamicfieldViewComposer.assignDynamicFieldsToPageObject
test
private function assignDynamicFieldsToPageObject($view) { $entityDynamic = null; $data = $view->getData(); //TODO Fix with event if (count($data)) { $arrType = config('asgard.dynamicfield.config.entity-type'); $arrType = array_keys($arrType); ...
php
{ "resource": "" }
q263311
Entity.getFieldByLocale
test
public function getFieldByLocale($locale = 'en') { $fields = $this->fields()->where('locale', $locale)->get(); if ($fields->count()) { $object = $fields[0]; } else { $object = new FieldTranslation(); } return $object; }
php
{ "resource": "" }
q263312
Entity.getRepeatersByLocale
test
public function getRepeatersByLocale($locale) { $repeaters = $this->repeaters() ->where('locale', $locale) ->orderBy('order') ->get(); return $repeaters; }
php
{ "resource": "" }
q263313
Entity.getEntitiesByFieldId
test
public function getEntitiesByFieldId($fieldId) { $values = $this->where('field_id', $fieldId)->get(); if ($values->count()) { $object = $values[0]; } else { $object = new self(); } return $object; }
php
{ "resource": "" }
q263314
Entity.scopeGetEntity
test
public function scopeGetEntity($query, $entityId, $entityType, $fieldId) { $entities = $query->where('entity_id', $entityId) ->where('entity_type', $entityType) ->where('field_id', $fieldId)->get(); if ($entities->count()) { $object = $enti...
php
{ "resource": "" }
q263315
Entity.duplicate
test
public function duplicate($pageId = 0) { $entity = $this->replicate(); $entity->entity_id = $pageId; $entity->save(); $type = $this->getFieldType(); if ($type != 'repeater') { $fields = $this->Fields; foreach ($fields as $translation) { ...
php
{ "resource": "" }
q263316
Entity.init
test
public function init($default = null) { //getGroupByRule $options['type'] = $this->type; $options['template'] = $this->template; $groups = $this->getGroupByRule($options); if (count($groups)) { foreach ($groups as $groupId) { $group = Group::find(...
php
{ "resource": "" }
q263317
Entity.valid
test
public function valid() { $isValid = true; if (count($this->groupFields)) { foreach ($this->groupFields as $group) { $fields = $group['fields']; foreach ($fields as $field) { $isValid = $field->valid(); if (!$isVali...
php
{ "resource": "" }
q263318
Entity.render
test
public function render() { $html = ''; if (count($this->groupFields)) { foreach ($this->groupFields as $group) { $htmlControl = ''; $fields = $group['fields']; foreach ($fields as $field) { $htmlControl .= $field->rend...
php
{ "resource": "" }
q263319
Entity.save
test
public function save() { $bResult = false; try { if (count($this->groupFields)) { foreach ($this->groupFields as $group) { $fields = $group['fields']; foreach ($fields as $field) { $field->save(); ...
php
{ "resource": "" }
q263320
Entity.getGroupByRule
test
public function getGroupByRule($options) { $arrResult = array(); $rules = Rule::all(); foreach ($rules as $rule) { $params = (array) json_decode($rule->rule); $defaultMatch = true; foreach ($params as $item) { $match = $this->matchRule((ar...
php
{ "resource": "" }
q263321
Entity.matchRule
test
private function matchRule($rule, $options) { $match = false; $type = array_get($rule, 'parameter', 'type'); $operator = array_get($rule, 'operator', 'equal'); $value = array_get($rule, 'value', 'default'); if ($operator == 'equal') { $match = ($value === $option...
php
{ "resource": "" }
q263322
Entity.initGroup
test
private function initGroup($group, $default = null) { $groupId = $group->id; $groupName = $group->name; $fields = $group->getListFields(); $fieldData = $this->getFieldPostData($default); $controls = array(); if ($fields->count()) { $this->fieldInDB = Enti...
php
{ "resource": "" }
q263323
Entity.getFieldPostData
test
private function getFieldPostData($data) { $arrData = array(); if (isset($data)) { $arrData = @$data[$this->locale]; } return $arrData; }
php
{ "resource": "" }
q263324
Canvas.set
test
public function set($x, $y) { list($x, $y, $px, $py) = $this->prime($x, $y); $this->chars[$py][$px] |= $this->getDotFromMap($x, $y); }
php
{ "resource": "" }
q263325
Canvas.get
test
public function get($x, $y) { list($x, $y, , , $char) = $this->prime($x, $y); return (bool) ($char & $this->getDotFromMap($x, $y)); }
php
{ "resource": "" }
q263326
Canvas.row
test
public function row($y, array $options = []) { $row = isset($this->chars[$y]) ? $this->chars[$y] : []; if (!isset($options['min_x']) || !isset($options['max_x'])) { if (!($keys = array_keys($row))) { return ''; } } $min = isset($options['min_x'])...
php
{ "resource": "" }
q263327
Canvas.rows
test
public function rows(array $options = []) { if (!isset($options['min_y']) || !isset($options['max_y'])) { if (!($keys = array_keys($this->chars))) { return []; } } $min = isset($options['min_y']) ? $options['min_y'] : min($keys); $max = isset($opt...
php
{ "resource": "" }
q263328
Canvas.getDotFromMap
test
private function getDotFromMap($x, $y) { $y = $y % 4; $x = $x % 2; return self::$pixel_map[$y < 0 ? 4 + $y : $y][$x < 0 ? 2 + $x : $x]; }
php
{ "resource": "" }
q263329
Canvas.prime
test
private function prime($x, $y) { $x = round($x); $y = round($y); $px = floor($x / 2); $py = floor($y / 4); if (!isset($this->chars[$py][$px])) { $this->chars[$py][$px] = 0; } return [$x, $y, $px, $py, $this->chars[$py][$px]]; }
php
{ "resource": "" }
q263330
Repeater.initRepeatFields
test
private function initRepeatFields($fieldInfo, $default = null) { $controls = array(); $repeaterId = $fieldInfo->id; $entity = Entity::getEntity($this->entityId, $this->entityType, $repeaterId); $repeaters = Entity::getAllDataTranactionRepeater($this->entityId, $this->entityType, $rep...
php
{ "resource": "" }
q263331
Repeater.createListControlAfterPostData
test
private function createListControlAfterPostData($repeaterId, $default = null, $fieldOfRepeater) { $controls = array(); $nameFormat = '%s[fields]' . sprintf('[%s][value][%s]', $this->getFieldId(), $repeaterId) . '[%s][value]'; $idFormat = '%s_' . sprintf('%s_%s_', $this->getFieldId(), $repeat...
php
{ "resource": "" }
q263332
Repeater.createListControl
test
private function createListControl($repeater, $fieldOfRepeater) { $nameFormat = '%s[fields]' . sprintf('[%s][value][%s]', $this->getFieldId(), $repeater->id) . '[%s][value]'; $idFormat = '%s_' . sprintf('%s_%s_', $this->getFieldId(), $repeater->id) . '_%s_value'; if ($fieldOfRepeater->count...
php
{ "resource": "" }
q263333
Repeater.createFieldControl
test
private function createFieldControl($field, $translateId, $default = null) { $fieldControl = null; $fieldValue = $default; switch ($field->type) { case 'text': $fieldControl = new Text($field, $this->entityId, $this->locale); break; cas...
php
{ "resource": "" }
q263334
Repeater.createHeaderRepeater
test
private function createHeaderRepeater($fieldOfRepeater) { $repeater = new RepeaterTranslation(); //TODO Here was ='clone' $repeater->id = 'clone'; $controls = $this->createListControl($repeater, $fieldOfRepeater); return $controls; }
php
{ "resource": "" }
q263335
Repeater.save
test
public function save() { $bResult = false; try { if (!empty($this->deleteItems)) { $items = explode(',', $this->deleteItems); RepeaterTranslation::destroy($items); } if (count($this->groupFields)) { foreach ($this->g...
php
{ "resource": "" }
q263336
Repeater.getDisplayValue
test
public function getDisplayValue() { $values = array(); if (count($this->groupFields)) { $i = 0; foreach ($this->groupFields as $key => $group) { $fields = $group['fields']; $item = array(); foreach ($fields as $field) { ...
php
{ "resource": "" }
q263337
RepeaterTranslation.getFieldValue
test
public function getFieldValue($fieldId) { $object = new RepeaterValue(); if (is_numeric($this->id)) { $repeatValues = $this->fieldValues()->where('field_id', $fieldId)->get(); if ($repeatValues->count()) { $object = $repeatValues[0]; } } ...
php
{ "resource": "" }
q263338
Template.getTemplateName
test
private function getTemplateName($template) { preg_match('/{{-- Template: (.*) --}}/', $template->getContents(), $templateName); if (count($templateName) > 1) { return $templateName[1]; } return $this->getDefaultTemplateName($template); }
php
{ "resource": "" }
q263339
Template.getDefaultTemplateName
test
private function getDefaultTemplateName($template) { $relativePath = $template->getRelativePath(); $fileName = $this->removeExtensionsFromFilename($template); return $this->hasSubdirectory($relativePath) ? $relativePath . '/' . $fileName : $fileName; }
php
{ "resource": "" }
q263340
FieldBase.init
test
public function init($default = null) { //$this->model = $this->getModel(); if (!isset($default)) { //$this->value = $this->model->value; if (empty($this->dataInDB)) { $this->value = $this->getOption('default'); } else { $this->valu...
php
{ "resource": "" }
q263341
FieldBase.getModel
test
public function getModel() { if (is_a($this->field, 'Modules\Dynamicfield\Entities\Field')) { $entity = Entity::getEntity($this->entityId, $this->entityType, $this->fieldId); $model = $entity->getFieldByLocale($this->locale); } else { $model = new RepeaterValue();...
php
{ "resource": "" }
q263342
FieldBase.getHtmlId
test
public function getHtmlId() { $strHtmlId = sprintf($this->htmlIdFormat, $this->locale, $this->fieldId); return $strHtmlId; }
php
{ "resource": "" }
q263343
FieldBase.getHtmlName
test
public function getHtmlName() { $strHtmlName = sprintf($this->htmlNameFormat, $this->locale, $this->fieldId); return $strHtmlName; }
php
{ "resource": "" }
q263344
FieldBase.save
test
public function save() { $this->model = $this->getModel(); if (is_a($this->model, 'Modules\Dynamicfield\Entities\FieldTranslation')) { $this->saveField(); } else { // save sub control of repeater $this->saveRepeaterField(); } }
php
{ "resource": "" }
q263345
FieldBase.saveField
test
public function saveField() { $entity = Entity::getEntity($this->entityId, $this->entityType, $this->fieldId); if (!$entity->id) { $entity->entity_id = $this->entityId; $entity->field_id = $this->fieldId; $entity->entity_type = $this->entityType; $enti...
php
{ "resource": "" }
q263346
FieldBase.saveRepeaterField
test
public function saveRepeaterField() { $repeaterId = $this->repeaterId; $repeaterTranslate = RepeaterTranslation::firstOrNew(array('id' => $this->translationId)); if (!$repeaterTranslate->id) { $entity = Entity::getEntity($this->entityId, $this->entityType, $repeaterId); ...
php
{ "resource": "" }
q263347
FieldBase.getOption
test
public function getOption($key) { $value = ''; try { $value = $this->options[$key]; } catch (\Exception $e) { } return $value; }
php
{ "resource": "" }
q263348
Turtle.forward
test
public function forward($length) { $theta = $this->rotation / 180.0 * M_PI; $x = $this->x + $length * cos($theta); $y = $this->y + $length * sin($theta); $this->move($x, $y); }
php
{ "resource": "" }
q263349
Turtle.move
test
public function move($x, $y) { if (!$this->up) { $x1 = round($this->x); $y1 = round($this->y); $x2 = $x; $y2 = $y; $xdiff = max($x1, $x2) - min($x1, $x2); $ydiff = max($y1, $y2) - min($y1, $y2); $xdir = $x1 <= $x2 ? 1 : -1; $ydir = $y1 <= $y2 ? 1 :...
php
{ "resource": "" }
q263350
TaskConfiguration.hasAncestor
test
public function hasAncestor(TaskConfiguration $taskConfig) { foreach ($this->getPreviousTasksConfigurations() as $previousTaskConfig) { // Avoid errors for direct ancestors if ($this->getCode() === $previousTaskConfig->getCode()) { continue; } ...
php
{ "resource": "" }
q263351
TaskConfiguration.hasDescendant
test
public function hasDescendant(TaskConfiguration $taskConfig, $checkErrors = true) { foreach ($this->getNextTasksConfigurations() as $nextTaskConfig) { // Avoid errors for direct descendant if ($this->getCode() === $nextTaskConfig->getCode()) { continue; } ...
php
{ "resource": "" }
q263352
ProcessState.reset
test
public function reset($cleanInput) { $this->setOutput(null); $this->setSkipped(false); $this->setException(null); $this->setErrorOutput(null); if($cleanInput) { $this->setInput(null); $this->setPreviousState(null); } }
php
{ "resource": "" }
q263353
ConditionTrait.checkCondition
test
protected function checkCondition($input, $conditions) { foreach ($conditions['match'] as $key => $value) { if (!$this->checkValue($input, $key, $value)) { return false; } } foreach ($conditions['empty'] as $key => $value) { if (!$this->ch...
php
{ "resource": "" }
q263354
ConditionTrait.configureWrappedConditionOptions
test
protected function configureWrappedConditionOptions(string $wrapperKey, OptionsResolver $resolver) { $resolver->setDefault($wrapperKey, []); $resolver->setAllowedTypes($wrapperKey, ['array']); $resolver->setNormalizer($wrapperKey, function (OptionsResolver $options, $value) { $co...
php
{ "resource": "" }
q263355
ConditionTrait.configureConditionOptions
test
protected function configureConditionOptions(OptionsResolver $resolver) { $resolver->setDefault('not_match', []); $resolver->setDefault('match', []); $resolver->setDefault('not_empty', []); $resolver->setDefault('empty', []); $resolver->setDefault('not_match_regexp', []); ...
php
{ "resource": "" }
q263356
ConditionTrait.checkValue
test
protected function checkValue($input, $key, $value, $shouldMatch = true, $regexpMode = false) { $currentValue = $this->getValue($input, $key); /** @noinspection TypeUnsafeComparisonInspection */ if ($shouldMatch && !$regexpMode && $currentValue != $value) { return false; ...
php
{ "resource": "" }
q263357
ConditionTrait.checkEmpty
test
protected function checkEmpty($input, $key) { $currentValue = $this->getValue($input, $key); return empty($currentValue); }
php
{ "resource": "" }
q263358
ProcessHistory.getDuration
test
public function getDuration() { if ($this->getEndDate()) { return $this->getEndDate()->getTimestamp() - $this->getStartDate()->getTimestamp(); } return null; }
php
{ "resource": "" }
q263359
ContextualOptionResolver.contextualizeOptions
test
public function contextualizeOptions(array $options, array $context): array { $contextualizedOptions = []; foreach ($options as $key => $value) { $contextualizedKey = $this->contextualizeOption($key, $context); $contextualizedValue = $this->contextualizeOption($value, $contex...
php
{ "resource": "" }
q263360
ProcessHelpCommand.findBestNextTask
test
protected function findBestNextTask($branches, $taskList, ProcessConfiguration $process) { // Get resolvable tasks $taskCandidates = []; foreach ($taskList as $taskCode) { $task = $process->getTaskConfiguration($taskCode); if (empty($task->getPreviousTasksConfiguratio...
php
{ "resource": "" }
q263361
InputAggregatorTask.getInputCode
test
protected function getInputCode(ProcessState $state) { $previousState = $state->getPreviousState(); $previousTaskCode = $previousState->getTaskConfiguration()->getCode(); $inputCodes = $this->getOption($state, 'input_codes'); if (!array_key_exists($previousTaskCode, $inputCodes)) { ...
php
{ "resource": "" }
q263362
InputAggregatorTask.isResolved
test
protected function isResolved(ProcessState $state) { $inputCodes = $this->getOption($state, 'input_codes'); foreach ($inputCodes as $inputCode) { if (!array_key_exists($inputCode, $this->inputs)) { return false; } } return true; }
php
{ "resource": "" }
q263363
InputCsvReaderTask.getFilePath
test
protected function getFilePath(array $options, string $input) { $basePath = $options['base_path']; if (\strlen($basePath) > 0) { $basePath = rtrim($options['base_path'], '/').'/'; } return $basePath.$input; }
php
{ "resource": "" }
q263364
ListProcessCommand.processSorter
test
public function processSorter(ProcessConfiguration $a, ProcessConfiguration $b) { if ($a->getCode() === $b->getCode()) { return 0; } return ($a->getCode() < $b->getCode()) ? -1 : 1; }
php
{ "resource": "" }
q263365
InputIteratorTask.handleIteratorFromInput
test
protected function handleIteratorFromInput(ProcessState $state) { if ($this->iterator instanceof \Iterator) { if ($this->iterator->valid()) { // No action needed, execution is in progress return; } // Cleanup invalid iterator => prepare for...
php
{ "resource": "" }
q263366
CounterTask.flush
test
public function flush(ProcessState $state): void { $modulo = $this->getOption($state, 'flush_every'); if (0 === $this->counter % $modulo) { $state->setSkipped(true); } else { $state->setOutput($this->counter); } }
php
{ "resource": "" }
q263367
CsvResource.getLineCount
test
public function getLineCount(): int { if (null === $this->lineCount) { $this->rewind(); $line = 0; while (!$this->isEndOfFile()) { ++$line; $this->readRaw(); } $this->rewind(); $this->lineCount = $line; ...
php
{ "resource": "" }
q263368
CsvResource.rewind
test
public function rewind(): void { $this->assertOpened(); if (!rewind($this->handler)) { throw new \RuntimeException("Unable to rewind '{$this->getResourceName()}'"); } $this->currentLine = 0; if (!$this->manualHeaders) { $this->readRaw(); // skip header...
php
{ "resource": "" }
q263369
TransformerTrait.getCleanedTransfomerCode
test
protected function getCleanedTransfomerCode(string $transformerCode) { $match = preg_match('/([^#]+)(#[\d]+)?/', $transformerCode, $parts); if (1 === $match && $this->transformerRegistry->hasTransformer($parts[1])) { return $parts[1]; } return $transformerCode; }
php
{ "resource": "" }
q263370
ProcessConfiguration.getDependencyGroups
test
public function getDependencyGroups(): array { if (null === $this->dependencyGroups) { $this->dependencyGroups = []; foreach ($this->getTaskConfigurations() as $taskConfiguration) { $isInBranch = false; foreach ($this->dependencyGroups as $branch) { ...
php
{ "resource": "" }
q263371
ProcessConfiguration.getMainTaskGroup
test
public function getMainTaskGroup(): array { if (null === $this->mainTaskGroup) { $mainTask = $this->getMainTask(); foreach ($this->getDependencyGroups() as $branch) { if (\in_array($mainTask->getCode(), $branch, true)) { $this->mainTaskGroup = $br...
php
{ "resource": "" }
q263372
ProcessConfiguration.checkCircularDependencies
test
public function checkCircularDependencies() { $taskConfigurations = $this->getTaskConfigurations(); foreach ($taskConfigurations as $taskConfiguration) { foreach ($taskConfiguration->getPreviousTasksConfigurations() as $previousTaskConfig) { if ($taskConfiguration->getCo...
php
{ "resource": "" }
q263373
ProcessConfiguration.buildDependencies
test
protected function buildDependencies(TaskConfiguration $taskConfig, array &$dependencies = []) { $code = $taskConfig->getCode(); // May have been added by previous task if (!\in_array($code, $dependencies, true)) { $dependencies[] = $code; foreach ($taskConfig->getP...
php
{ "resource": "" }
q263374
ProcessConfiguration.sortDependencies
test
protected function sortDependencies(array $dependencies) { if (\count($dependencies) <= 1) { return $dependencies; } try { $this->checkCircularDependencies(); } catch (CircularProcessException $e) { // Skipping the sort phase, it will throw later,...
php
{ "resource": "" }
q263375
ProcessManager.resolve
test
protected function resolve(TaskConfiguration $taskConfiguration): bool { $state = $taskConfiguration->getState(); if ($state->isResolved()) { return true; } $state->setStatus(ProcessState::STATUS_PENDING); // Resolve parents first $allParentsResolved = t...
php
{ "resource": "" }
q263376
ProcessManager.initialize
test
protected function initialize(TaskConfiguration $taskConfiguration): void { $this->taskConfiguration = $taskConfiguration; if ($taskConfiguration->getErrorStrategy() === TaskConfiguration::STRATEGY_STOP && \count($taskConfiguration->getErrorOutputs()) > 0) { $m = "Task confi...
php
{ "resource": "" }
q263377
ProcessManager.flush
test
protected function flush(TaskConfiguration $taskConfiguration): void { $task = $taskConfiguration->getTask(); if ($task instanceof BlockingTaskInterface) { return; } if ($task instanceof FlushableTaskInterface) { $this->process($taskConfiguration, self::EXECUT...
php
{ "resource": "" }
q263378
ProcessManager.handleState
test
protected function handleState(ProcessState $state): void { $processHistory = $state->getProcessHistory(); if ($state->getException() && $state->isStopped()) { $processHistory->setFailed(); throw new \RuntimeException( "Process {$state->getProcessConfiguratio...
php
{ "resource": "" }
q263379
ProcessManager.checkProcess
test
protected function checkProcess(ProcessConfiguration $processConfiguration): void { $processConfiguration->checkCircularDependencies(); $taskConfigurations = $processConfiguration->getTaskConfigurations(); $mainTaskList = $processConfiguration->getMainTaskGroup(); $entryPoint = $pro...
php
{ "resource": "" }
q263380
Model._validateModel
test
protected static function _validateModel() { // check if model is already validate if (!isset(self::$_validationStatus[static::$_databaseName . static::$_tableName])) { // grab actual class name from late state binding $subClassName = get_class(new static()); //...
php
{ "resource": "" }
q263381
Model.toArray
test
public function toArray($includePrimary = true) { if ($includePrimary) { $array = array(static::$_primaryKey => $this->{static::$_primaryKey}); } else { $array = array(); } foreach (static::$_tableFields as $unChamp) { $array[$unChamp] = $this->{$...
php
{ "resource": "" }
q263382
Model.getModelFields
test
public static function getModelFields($includePrimary = true) { $fields = array(); if ($includePrimary) { $fields[] = static::$_primaryKey; } foreach (static::$_tableFields as $unChamp) { $fields[] = $unChamp; } return $fields; }
php
{ "resource": "" }
q263383
Model._unsetRelation
test
private function _unsetRelation(array $configRelation, $callArgs) { $isDeleted = false; switch ($configRelation['typeRelation']) { case self::MANY_TO_MANY: // assure that we provide an array of relation to unset if (!is_array($callArgs[0])) { ...
php
{ "resource": "" }
q263384
Model.formatClassnameToRelationName
test
protected static function formatClassnameToRelationName($fullClassName) { // test if namespace present and remove them if (strpos($fullClassName, '\\') !== false) { $fullClassName = explode('\\', $fullClassName); $fullClassName = array_pop($fullClassName); } ...
php
{ "resource": "" }
q263385
Model.addRelationOneToOne
test
protected static function addRelationOneToOne( $sourceField, $classRelation, $targetField, $autoGetFields = array(), $aliasRelation = '' ) { if (!is_string($sourceField)) { throw new Exception('$sourceField have to be a string'); } if (...
php
{ "resource": "" }
q263386
Model.addRelationOneToMany
test
protected static function addRelationOneToMany($sourceField, $classRelation, $targetField, $aliasRelation = '') { // test is related class is a PicORM model if (!class_exists($classRelation) || !new $classRelation() instanceof Model) { throw new Exception("Class " . $classRelation . " do...
php
{ "resource": "" }
q263387
Model.addRelationManyToMany
test
protected static function addRelationManyToMany( $sourceField, $classRelation, $targetField, $relationTable, $aliasRelation = '' ) { // test is related class is a PicORM model if (!class_exists($classRelation) || !new $classRelation() instanceof Model) { ...
php
{ "resource": "" }
q263388
Model.findQuery
test
public static function findQuery($query, $params) { $query = static::$_dataSource->prepare($query); $query->execute($params); $fetch = $query->fetchAll(\PDO::FETCH_ASSOC); $collection = array(); foreach ($fetch as $unRes) { $object = new static(); $ob...
php
{ "resource": "" }
q263389
Model.find
test
public static function find($where = array(), $order = array(), $limitStart = null, $limitEnd = null) { // validate model PHP structure if necessary self :: _validateModel(); // build a query helper with parameters $queryHelper = static::buildSelectQuery(array("*"), $where, $order, ...
php
{ "resource": "" }
q263390
Model.findOne
test
public static function findOne($where = array(), $order = array()) { // try to fetch a model from database if ($dataModel = self::select(array('*'), $where, $order, 1)) { // hydrate new model instance with fetched data $model = new static(); $model->hydrate($data...
php
{ "resource": "" }
q263391
Model.count
test
public static function count($where = array()) { // fetch the count with $where parameters $rawSqlFetch = self::select(array("count(*) as nb"), $where); return isset($rawSqlFetch[0]) && isset($rawSqlFetch[0]['nb']) ? (int)$rawSqlFetch[0]['nb'] : null; }
php
{ "resource": "" }
q263392
Model.buildSelectQuery
test
protected static function buildSelectQuery( $fields = array('*'), $where = array(), $order = array(), $limitStart = null, $limitEnd = null ) { // get the formatted model mysql table name with database name $modelTableName = static::formatTableNameMySQL(); ...
php
{ "resource": "" }
q263393
Model.select
test
public static function select( $fields = array('*'), $where = array(), $order = array(), $limitStart = null, $limitEnd = null, $pdoFetchMode = null ) { // validate model PHP structure if necessary static::_validateModel(); // build and exe...
php
{ "resource": "" }
q263394
Model.hydrate
test
public function hydrate($data, $strictLoad = true) { // using reflection to check if property exist $reflection = new \ReflectionObject($this); foreach ($data as $k => $v) { // if strictLoad is disabled, all properties are allowed to be hydrated if (!$strictLoad) { ...
php
{ "resource": "" }
q263395
Model.delete
test
public function delete() { // validate model PHP structure if necessary static::_validateModel(); // build delete query helper for this model $query = new InternalQueryHelper(); $query->delete(self::formatTableNameMySQL()) ->where(static::$_primaryKey, "=", "?"...
php
{ "resource": "" }
q263396
Model.update
test
private function update() { // validate model PHP structure if necessary static::_validateModel(); // build update query on model table $helper = new InternalQueryHelper(); $helper->update(self::formatTableNameMySQL()); // setting model fields value $params ...
php
{ "resource": "" }
q263397
Model.insert
test
private function insert() { // validate model PHP structure if necessary static::_validateModel(); // create insert query for this model $queryHelp = new InternalQueryHelper(); $queryHelp->insertInto(self::formatTableNameMySQL()); // if primary key has forced value ...
php
{ "resource": "" }
q263398
Collection.keep_memory
test
public function keep_memory( $keep_memory = true ) { $prev = $this->keep_memory; $this->keep_memory = $keep_memory; return $prev; }
php
{ "resource": "" }
q263399
Collection.dont_remember
test
public function dont_remember( Closure $callback ) { $prev = $this->keep_memory( false ); $callback( $this ); $this->keep_memory( $prev ); }
php
{ "resource": "" }