repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ModelBuilder.php | ModelBuilder.build | private function build() {
$this->getAbstractClass()->setDocumentation($this->getComment());
$this->getAbstractClass()->setName(ucfirst($this->getTableName()));
$this->getAbstractClass()->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Base'
);
$this->getAbstractClass()->addUse('Bullhorn\FastRest\Api\Models\GeneratedInterface');
$this->getAbstractClass()->setImplements(['GeneratedInterface']);
$this->getAbstractClass()->setNamespace(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Generated'
);
$this->getAbstractClass()->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\\' . ucfirst($this->getTableName()) . ' as ChildModel'
);
$this->getAbstractClass()->setExtends('Base');
$this->getAbstractClass()->setAbstract(true);
$this->buildIdField();
$this->buildEnumConstants();
$this->buildInitialize();
$this->buildFieldsTypes();
$this->buildVariableDefinitions();
$this->buildOnConstruct();
$this->buildGetSource();
$this->buildAddJoin();
$this->buildFindFirst();
$this->buildFind();
$this->buildGettersAndSetters();
$this->buildRelationshipGetters();
$this->buildColumnMap();
$this->buildRelationshipsList();
} | php | private function build() {
$this->getAbstractClass()->setDocumentation($this->getComment());
$this->getAbstractClass()->setName(ucfirst($this->getTableName()));
$this->getAbstractClass()->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Base'
);
$this->getAbstractClass()->addUse('Bullhorn\FastRest\Api\Models\GeneratedInterface');
$this->getAbstractClass()->setImplements(['GeneratedInterface']);
$this->getAbstractClass()->setNamespace(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Generated'
);
$this->getAbstractClass()->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\\' . ucfirst($this->getTableName()) . ' as ChildModel'
);
$this->getAbstractClass()->setExtends('Base');
$this->getAbstractClass()->setAbstract(true);
$this->buildIdField();
$this->buildEnumConstants();
$this->buildInitialize();
$this->buildFieldsTypes();
$this->buildVariableDefinitions();
$this->buildOnConstruct();
$this->buildGetSource();
$this->buildAddJoin();
$this->buildFindFirst();
$this->buildFind();
$this->buildGettersAndSetters();
$this->buildRelationshipGetters();
$this->buildColumnMap();
$this->buildRelationshipsList();
} | [
"private",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"getAbstractClass",
"(",
")",
"->",
"setDocumentation",
"(",
"$",
"this",
"->",
"getComment",
"(",
")",
")",
";",
"$",
"this",
"->",
"getAbstractClass",
"(",
")",
"->",
"setName",
"(",
"... | Builds the buffer
@return void | [
"Builds",
"the",
"buffer"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L1234-L1275 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ModelBuilder.php | ModelBuilder.buildChild | private function buildChild() {
$class = new Object\Index($this->getConfiguration());
$class->setName(ucfirst($this->getTableName()));
$class->setAbstract(false);
$class->setExtends('GeneratedParent');
$class->setNamespace(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
);
$class->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Generated\\' . ucfirst($this->getTableName()) . ' as GeneratedParent'
);
$method = new Object\Method();
$method->setDescription('This should set any defaults to the current object');
$method->setName('loadDefaults');
$method->setContent('//TODO');
$method->setAccess('public');
$method->setReturnType('void');
$class->addMethod($method);
return $class;
} | php | private function buildChild() {
$class = new Object\Index($this->getConfiguration());
$class->setName(ucfirst($this->getTableName()));
$class->setAbstract(false);
$class->setExtends('GeneratedParent');
$class->setNamespace(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
);
$class->addUse(
$this->getConfiguration()->getRootNamespace()
. '\Models\\' . $this->getConfiguration()->getModelSubNamespace()
. '\Generated\\' . ucfirst($this->getTableName()) . ' as GeneratedParent'
);
$method = new Object\Method();
$method->setDescription('This should set any defaults to the current object');
$method->setName('loadDefaults');
$method->setContent('//TODO');
$method->setAccess('public');
$method->setReturnType('void');
$class->addMethod($method);
return $class;
} | [
"private",
"function",
"buildChild",
"(",
")",
"{",
"$",
"class",
"=",
"new",
"Object",
"\\",
"Index",
"(",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
")",
";",
"$",
"class",
"->",
"setName",
"(",
"ucfirst",
"(",
"$",
"this",
"->",
"getTableName"... | Builds the child buffer
@return Object\Index | [
"Builds",
"the",
"child",
"buffer"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L1361-L1385 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ModelBuilder.php | ModelBuilder.write | public function write() {
$this->getAbstractClass()->write();
$child = $this->buildChild();
if(!file_exists($child->getFileName())) {
$child->write();
}
$this->buildTestTable()->write();
$this->getValidationClass()->write();
if(!file_exists($this->getValidationChildClass()->getFileName())) {
$this->getValidationChildClass()->write();
}
} | php | public function write() {
$this->getAbstractClass()->write();
$child = $this->buildChild();
if(!file_exists($child->getFileName())) {
$child->write();
}
$this->buildTestTable()->write();
$this->getValidationClass()->write();
if(!file_exists($this->getValidationChildClass()->getFileName())) {
$this->getValidationChildClass()->write();
}
} | [
"public",
"function",
"write",
"(",
")",
"{",
"$",
"this",
"->",
"getAbstractClass",
"(",
")",
"->",
"write",
"(",
")",
";",
"$",
"child",
"=",
"$",
"this",
"->",
"buildChild",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"child",
"->",
... | Writes to a file
@return void | [
"Writes",
"to",
"a",
"file"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ModelBuilder.php#L1430-L1441 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildRelatedModels | private function buildRelatedModels() {
/** @var Base[] $relatedModels */
$relatedModels = array();
/** @var ModelBuilder[] $relatedBuilders */
$relatedBuilders = array();
$automaticallyUpdatedFields = $this->getModel()->getAutomaticallyUpdatedFields();
foreach($this->getModel()->getDefaultRelationships() as $alias) {
$relation = $this->getModel()->getModelsManager()->getRelationByAlias(get_class($this->getModel()), $alias);
if($relation !== false) {
if(in_array($relation->getFields(), $automaticallyUpdatedFields)) {
$referencedModel = $relation->getReferencedModel();
/** @var Base $relatedModel */
$relatedModel = new $referencedModel();
$relatedModels[$alias] = $relatedModel;
$relatedBuilders[$alias] = new ModelBuilder($this->getConfiguration(), $relatedModel->getSource());
}
}
}
$this->setRelatedModels($relatedModels);
$this->setRelatedBuilders($relatedBuilders);
} | php | private function buildRelatedModels() {
/** @var Base[] $relatedModels */
$relatedModels = array();
/** @var ModelBuilder[] $relatedBuilders */
$relatedBuilders = array();
$automaticallyUpdatedFields = $this->getModel()->getAutomaticallyUpdatedFields();
foreach($this->getModel()->getDefaultRelationships() as $alias) {
$relation = $this->getModel()->getModelsManager()->getRelationByAlias(get_class($this->getModel()), $alias);
if($relation !== false) {
if(in_array($relation->getFields(), $automaticallyUpdatedFields)) {
$referencedModel = $relation->getReferencedModel();
/** @var Base $relatedModel */
$relatedModel = new $referencedModel();
$relatedModels[$alias] = $relatedModel;
$relatedBuilders[$alias] = new ModelBuilder($this->getConfiguration(), $relatedModel->getSource());
}
}
}
$this->setRelatedModels($relatedModels);
$this->setRelatedBuilders($relatedBuilders);
} | [
"private",
"function",
"buildRelatedModels",
"(",
")",
"{",
"/** @var Base[] $relatedModels */",
"$",
"relatedModels",
"=",
"array",
"(",
")",
";",
"/** @var ModelBuilder[] $relatedBuilders */",
"$",
"relatedBuilders",
"=",
"array",
"(",
")",
";",
"$",
"automaticallyUpd... | Builds the related required models, such as user to employee
@return void | [
"Builds",
"the",
"related",
"required",
"models",
"such",
"as",
"user",
"to",
"employee"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L109-L129 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildDocumentation | private function buildDocumentation() {
$model = new Swagger\Model();
$model->setId($this->getClassName());
$this->buildProperties($model);
foreach($this->getRelatedModels() as $alias => $relatedModel) {
$this->buildProperties($model, $alias);
}
$resource = new Swagger\Resource();
$resource->setApiVersion('1.0')->setBasePath('/v1.0')->setResourcePath($this->getClassName());
$resource->setDescription('');
$documentation = $model . "\n" . $resource;
$this->getObject()->setDocumentation($documentation);
} | php | private function buildDocumentation() {
$model = new Swagger\Model();
$model->setId($this->getClassName());
$this->buildProperties($model);
foreach($this->getRelatedModels() as $alias => $relatedModel) {
$this->buildProperties($model, $alias);
}
$resource = new Swagger\Resource();
$resource->setApiVersion('1.0')->setBasePath('/v1.0')->setResourcePath($this->getClassName());
$resource->setDescription('');
$documentation = $model . "\n" . $resource;
$this->getObject()->setDocumentation($documentation);
} | [
"private",
"function",
"buildDocumentation",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Swagger",
"\\",
"Model",
"(",
")",
";",
"$",
"model",
"->",
"setId",
"(",
"$",
"this",
"->",
"getClassName",
"(",
")",
")",
";",
"$",
"this",
"->",
"buildProperties"... | Builds the class documentation
@return void | [
"Builds",
"the",
"class",
"documentation"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L256-L268 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildIndexAction | private function buildIndexAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName());
$operation = new Swagger\Operation();
$operation->setMethod('GET');
$operation->setSummary('Lists all ' . $this->getClassName() . '.');
$operation->setNotes(
'Only returns the first 50 by default. Using the actual API you can search by parent fields and any field on the model as opposed to the brief list provided below.'
);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage('List of ' . $this->getClassName() . '.');
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$operation->addParameter($this->buildStartParameter());
$operation->addParameter($this->buildCountParameter());
$operation->addParameter($this->buildSortParameter());
$operation->addParameter($this->buildFieldsParameter());
$searchParameters = $this->buildSearchParameters();
foreach($searchParameters as $searchParameter) {
$operation->addParameter($searchParameter);
}
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('indexAction');
$method->setContent('parent::indexAction();');
$this->getObject()->addMethod($method);
} | php | private function buildIndexAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName());
$operation = new Swagger\Operation();
$operation->setMethod('GET');
$operation->setSummary('Lists all ' . $this->getClassName() . '.');
$operation->setNotes(
'Only returns the first 50 by default. Using the actual API you can search by parent fields and any field on the model as opposed to the brief list provided below.'
);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage('List of ' . $this->getClassName() . '.');
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$operation->addParameter($this->buildStartParameter());
$operation->addParameter($this->buildCountParameter());
$operation->addParameter($this->buildSortParameter());
$operation->addParameter($this->buildFieldsParameter());
$searchParameters = $this->buildSearchParameters();
foreach($searchParameters as $searchParameter) {
$operation->addParameter($searchParameter);
}
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('indexAction');
$method->setContent('parent::indexAction();');
$this->getObject()->addMethod($method);
} | [
"private",
"function",
"buildIndexAction",
"(",
")",
"{",
"$",
"api",
"=",
"new",
"Swagger",
"\\",
"Api",
"(",
")",
";",
"$",
"api",
"->",
"setPath",
"(",
"'/'",
".",
"$",
"this",
"->",
"getClassName",
"(",
")",
")",
";",
"$",
"operation",
"=",
"ne... | Builds the index action
@return void | [
"Builds",
"the",
"index",
"action"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L289-L327 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildUpdateAction | private function buildUpdateAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName() . '/{id}');
$operation = new Swagger\Operation();
$operation->setMethod('PUT');
$operation->setSummary('Update ' . $this->singularModelA_Or_An() . '.');
$operation->setNotes('Update ' . $this->singularModelA_Or_An() . '.');
$operation->addParameter($this->buildIdParameter());
$operation->addParameter($this->buildFieldsParameter());
$parameter = new Swagger\Parameter();
$parameter->setName('body');
$parameter->setDescription($this->getPutPostBodyDescription(false));
$parameter->setParamType('body');
$parameter->setType($this->getClassName());
$operation->addParameter($parameter);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' was updated.');
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(304);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' was not changed.');
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notFoundResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidValuePassed();
$operation->addResponseMessage($responseMessage);
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('updateAction');
$method->setContent('parent::updateAction();');
$this->getObject()->addMethod($method);
} | php | private function buildUpdateAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName() . '/{id}');
$operation = new Swagger\Operation();
$operation->setMethod('PUT');
$operation->setSummary('Update ' . $this->singularModelA_Or_An() . '.');
$operation->setNotes('Update ' . $this->singularModelA_Or_An() . '.');
$operation->addParameter($this->buildIdParameter());
$operation->addParameter($this->buildFieldsParameter());
$parameter = new Swagger\Parameter();
$parameter->setName('body');
$parameter->setDescription($this->getPutPostBodyDescription(false));
$parameter->setParamType('body');
$parameter->setType($this->getClassName());
$operation->addParameter($parameter);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' was updated.');
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(304);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' was not changed.');
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notFoundResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidValuePassed();
$operation->addResponseMessage($responseMessage);
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('updateAction');
$method->setContent('parent::updateAction();');
$this->getObject()->addMethod($method);
} | [
"private",
"function",
"buildUpdateAction",
"(",
")",
"{",
"$",
"api",
"=",
"new",
"Swagger",
"\\",
"Api",
"(",
")",
";",
"$",
"api",
"->",
"setPath",
"(",
"'/'",
".",
"$",
"this",
"->",
"getClassName",
"(",
")",
".",
"'/{id}'",
")",
";",
"$",
"ope... | Builds the update action
@return void | [
"Builds",
"the",
"update",
"action"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L486-L535 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildShowAction | private function buildShowAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName() . '/{id}');
$operation = new Swagger\Operation();
$operation->setMethod('GET');
$operation->setSummary('Find ' . ucfirst($this->getModel()->getSource()) . ' by id.');
$operation->setNotes('Returns ' . $this->singularModelA_Or_An() . ' based on ID.');
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()));
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notFoundResponse();
$operation->addResponseMessage($responseMessage);
$operation->addParameter($this->buildIdParameter());
$operation->addParameter($this->buildFieldsParameter());
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('showAction');
$method->setContent('parent::showAction();');
$this->getObject()->addMethod($method);
} | php | private function buildShowAction() {
$api = new Swagger\Api();
$api->setPath('/' . $this->getClassName() . '/{id}');
$operation = new Swagger\Operation();
$operation->setMethod('GET');
$operation->setSummary('Find ' . ucfirst($this->getModel()->getSource()) . ' by id.');
$operation->setNotes('Returns ' . $this->singularModelA_Or_An() . ' based on ID.');
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(200);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()));
$responseMessage->setResponseModel($this->getClassName());
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->invalidFieldSpecifiedError();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notAuthorizedResponse();
$operation->addResponseMessage($responseMessage);
$responseMessage = $this->notFoundResponse();
$operation->addResponseMessage($responseMessage);
$operation->addParameter($this->buildIdParameter());
$operation->addParameter($this->buildFieldsParameter());
$api->addOperation($operation);
$method = new Object\Method();
$method->setDescription($api->__toString());
$method->setReturnType('void');
$method->setAccess('public');
$method->setName('showAction');
$method->setContent('parent::showAction();');
$this->getObject()->addMethod($method);
} | [
"private",
"function",
"buildShowAction",
"(",
")",
"{",
"$",
"api",
"=",
"new",
"Swagger",
"\\",
"Api",
"(",
")",
";",
"$",
"api",
"->",
"setPath",
"(",
"'/'",
".",
"$",
"this",
"->",
"getClassName",
"(",
")",
".",
"'/{id}'",
")",
";",
"$",
"opera... | Builds the show action
@return void | [
"Builds",
"the",
"show",
"action"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L541-L575 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildFieldsParameter | private function buildFieldsParameter() {
list($parentEntities, $childrenEntities) = $this->getParentAndChildrenEntities();
$parameter = new Swagger\Parameter();
$parameter->setName('fields');
$parameter->setDescription(
'Can be fields on this entity, parent entities, or children entities. Specify entities other than this one with type.field. Eligible entities are: '
. implode(', ', array_merge($parentEntities, $childrenEntities)) . '. Optional.'
);
$parameter->setParamType('query');
$parameter->setType('string');
$parameter->setAllowMultiple(true);
return $parameter;
} | php | private function buildFieldsParameter() {
list($parentEntities, $childrenEntities) = $this->getParentAndChildrenEntities();
$parameter = new Swagger\Parameter();
$parameter->setName('fields');
$parameter->setDescription(
'Can be fields on this entity, parent entities, or children entities. Specify entities other than this one with type.field. Eligible entities are: '
. implode(', ', array_merge($parentEntities, $childrenEntities)) . '. Optional.'
);
$parameter->setParamType('query');
$parameter->setType('string');
$parameter->setAllowMultiple(true);
return $parameter;
} | [
"private",
"function",
"buildFieldsParameter",
"(",
")",
"{",
"list",
"(",
"$",
"parentEntities",
",",
"$",
"childrenEntities",
")",
"=",
"$",
"this",
"->",
"getParentAndChildrenEntities",
"(",
")",
";",
"$",
"parameter",
"=",
"new",
"Swagger",
"\\",
"Paramete... | Builds and returns the parameter of fields
@return Swagger\Parameter | [
"Builds",
"and",
"returns",
"the",
"parameter",
"of",
"fields"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L626-L639 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildIdParameter | private function buildIdParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('id');
$parameter->setDescription('Which ' . ucfirst($this->getModel()->getSource()) . ' to target.');
$parameter->setParamType('path');
$parameter->setType('integer');
$parameter->setRequired(true);
return $parameter;
} | php | private function buildIdParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('id');
$parameter->setDescription('Which ' . ucfirst($this->getModel()->getSource()) . ' to target.');
$parameter->setParamType('path');
$parameter->setType('integer');
$parameter->setRequired(true);
return $parameter;
} | [
"private",
"function",
"buildIdParameter",
"(",
")",
"{",
"$",
"parameter",
"=",
"new",
"Swagger",
"\\",
"Parameter",
"(",
")",
";",
"$",
"parameter",
"->",
"setName",
"(",
"'id'",
")",
";",
"$",
"parameter",
"->",
"setDescription",
"(",
"'Which '",
".",
... | Builds the id parameter
@return Swagger\Parameter | [
"Builds",
"the",
"id",
"parameter"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L645-L654 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildStartParameter | private function buildStartParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('start');
$parameter->setDescription('Which record to start retrieving results from in the database. Defaults to 0 which is the first record. Optional.');
$parameter->setParamType('query');
$parameter->setType('integer');
return $parameter;
} | php | private function buildStartParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('start');
$parameter->setDescription('Which record to start retrieving results from in the database. Defaults to 0 which is the first record. Optional.');
$parameter->setParamType('query');
$parameter->setType('integer');
return $parameter;
} | [
"private",
"function",
"buildStartParameter",
"(",
")",
"{",
"$",
"parameter",
"=",
"new",
"Swagger",
"\\",
"Parameter",
"(",
")",
";",
"$",
"parameter",
"->",
"setName",
"(",
"'start'",
")",
";",
"$",
"parameter",
"->",
"setDescription",
"(",
"'Which record... | Builds the start parameter
@return Swagger\Parameter | [
"Builds",
"the",
"start",
"parameter"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L660-L668 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildCountParameter | private function buildCountParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('count');
$parameter->setDescription('How many records to retrieve from the start point. Optional.');
$parameter->setParamType('query');
$parameter->setType('integer');
return $parameter;
} | php | private function buildCountParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('count');
$parameter->setDescription('How many records to retrieve from the start point. Optional.');
$parameter->setParamType('query');
$parameter->setType('integer');
return $parameter;
} | [
"private",
"function",
"buildCountParameter",
"(",
")",
"{",
"$",
"parameter",
"=",
"new",
"Swagger",
"\\",
"Parameter",
"(",
")",
";",
"$",
"parameter",
"->",
"setName",
"(",
"'count'",
")",
";",
"$",
"parameter",
"->",
"setDescription",
"(",
"'How many rec... | Builds the count parameter
@return Swagger\Parameter | [
"Builds",
"the",
"count",
"parameter"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L674-L682 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildSortParameter | private function buildSortParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('sort');
$parameter->setDescription(
'Any field on the model can be a sort field. The sort can contain multiple fields, comma separated.
It is also possible to get a reverse sort by adding a - in front of the field . Optional.'
);
$parameter->setParamType('query');
$parameter->setType('string');
return $parameter;
} | php | private function buildSortParameter() {
$parameter = new Swagger\Parameter();
$parameter->setName('sort');
$parameter->setDescription(
'Any field on the model can be a sort field. The sort can contain multiple fields, comma separated.
It is also possible to get a reverse sort by adding a - in front of the field . Optional.'
);
$parameter->setParamType('query');
$parameter->setType('string');
return $parameter;
} | [
"private",
"function",
"buildSortParameter",
"(",
")",
"{",
"$",
"parameter",
"=",
"new",
"Swagger",
"\\",
"Parameter",
"(",
")",
";",
"$",
"parameter",
"->",
"setName",
"(",
"'sort'",
")",
";",
"$",
"parameter",
"->",
"setDescription",
"(",
"'Any field on t... | Builds the sort parameter
@return Swagger\Parameter | [
"Builds",
"the",
"sort",
"parameter"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L688-L699 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.buildSearchParameters | private function buildSearchParameters() {
$fields = $this->getModelBuilder()->getFields();
$numberOfFields = sizeof($fields);
if($numberOfFields > 5) {
$numberOfFields = 5;
}
$parameters = array();
for($i = 0; $i < $numberOfFields; $i++) {
$parameter = new Swagger\Parameter();
$parameter->setName($fields[$i]->getShortName());
$parameter->setDescription($fields[$i]->getComment());
$parameter->setParamType('query');
$parameter->setType($fields[$i]->getSwaggerType());
$parameters[] = $parameter;
}
return $parameters;
} | php | private function buildSearchParameters() {
$fields = $this->getModelBuilder()->getFields();
$numberOfFields = sizeof($fields);
if($numberOfFields > 5) {
$numberOfFields = 5;
}
$parameters = array();
for($i = 0; $i < $numberOfFields; $i++) {
$parameter = new Swagger\Parameter();
$parameter->setName($fields[$i]->getShortName());
$parameter->setDescription($fields[$i]->getComment());
$parameter->setParamType('query');
$parameter->setType($fields[$i]->getSwaggerType());
$parameters[] = $parameter;
}
return $parameters;
} | [
"private",
"function",
"buildSearchParameters",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getModelBuilder",
"(",
")",
"->",
"getFields",
"(",
")",
";",
"$",
"numberOfFields",
"=",
"sizeof",
"(",
"$",
"fields",
")",
";",
"if",
"(",
"$",
"nu... | Builds a list of search parameters
@return Swagger\Parameter[] | [
"Builds",
"a",
"list",
"of",
"search",
"parameters"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L705-L722 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.build | private function build() {
$this->getObject()->addUse('Bullhorn\FastRest\Api\Models\ApiInterface as ModelInterface');
$this->getObject()->setName(ucfirst(strtolower($this->getClassName())) . 'Controller');
$this->getObject()->setNamespace($this->getConfiguration()->getRootNamespace() . '\Controllers');
$this->getObject()->setExtends('ControllerBase');
$this->buildFactory();
$this->buildIndexAction();
$this->buildShowAction();
$this->buildCreateAction();
$this->buildUpdateAction();
$this->buildDeleteAction();
$this->buildDocumentation();
} | php | private function build() {
$this->getObject()->addUse('Bullhorn\FastRest\Api\Models\ApiInterface as ModelInterface');
$this->getObject()->setName(ucfirst(strtolower($this->getClassName())) . 'Controller');
$this->getObject()->setNamespace($this->getConfiguration()->getRootNamespace() . '\Controllers');
$this->getObject()->setExtends('ControllerBase');
$this->buildFactory();
$this->buildIndexAction();
$this->buildShowAction();
$this->buildCreateAction();
$this->buildUpdateAction();
$this->buildDeleteAction();
$this->buildDocumentation();
} | [
"private",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"getObject",
"(",
")",
"->",
"addUse",
"(",
"'Bullhorn\\FastRest\\Api\\Models\\ApiInterface as ModelInterface'",
")",
";",
"$",
"this",
"->",
"getObject",
"(",
")",
"->",
"setName",
"(",
"ucfirst"... | Builds the class
@return void | [
"Builds",
"the",
"class"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L728-L740 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.notFoundResponse | private function notFoundResponse() {
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(404);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' not found.');
return $responseMessage;
} | php | private function notFoundResponse() {
$responseMessage = new Swagger\ResponseMessage();
$responseMessage->setCode(404);
$responseMessage->setMessage(ucfirst($this->getModel()->getSource()) . ' not found.');
return $responseMessage;
} | [
"private",
"function",
"notFoundResponse",
"(",
")",
"{",
"$",
"responseMessage",
"=",
"new",
"Swagger",
"\\",
"ResponseMessage",
"(",
")",
";",
"$",
"responseMessage",
"->",
"setCode",
"(",
"404",
")",
";",
"$",
"responseMessage",
"->",
"setMessage",
"(",
"... | Unable to find the requested resource.
@return Swagger\ResponseMessage | [
"Unable",
"to",
"find",
"the",
"requested",
"resource",
"."
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L788-L794 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.getParentAndChildrenEntities | private function getParentAndChildrenEntities() {
$parentEntities = array();
$childrenEntities = array();
foreach($this->getModelBuilder()->getRelationships() as $relationship) {
if($relationship->isPlural()) {
$parentEntities[] = $relationship->getAlias() . '.*';
} else {
$childrenEntities[] = $relationship->getAlias() . '.*';
}
}
return array($parentEntities, $childrenEntities);
} | php | private function getParentAndChildrenEntities() {
$parentEntities = array();
$childrenEntities = array();
foreach($this->getModelBuilder()->getRelationships() as $relationship) {
if($relationship->isPlural()) {
$parentEntities[] = $relationship->getAlias() . '.*';
} else {
$childrenEntities[] = $relationship->getAlias() . '.*';
}
}
return array($parentEntities, $childrenEntities);
} | [
"private",
"function",
"getParentAndChildrenEntities",
"(",
")",
"{",
"$",
"parentEntities",
"=",
"array",
"(",
")",
";",
"$",
"childrenEntities",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getModelBuilder",
"(",
")",
"->",
"getRelation... | Return the parent and children entities for this model
@return array | [
"Return",
"the",
"parent",
"and",
"children",
"entities",
"for",
"this",
"model"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L800-L812 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/ControllerBuilder.php | ControllerBuilder.getDeletionPreventingParents | private function getDeletionPreventingParents() {
$parentEntities = array();
foreach($this->getModelBuilder()->getRelationships() as $relationship) {
if($relationship->isPlural() && !$relationship->isNullable() && $relationship->getAction() != 'ACTION_CASCADE') {
$parentEntities[] = $relationship->getAlias();
}
}
return $parentEntities;
} | php | private function getDeletionPreventingParents() {
$parentEntities = array();
foreach($this->getModelBuilder()->getRelationships() as $relationship) {
if($relationship->isPlural() && !$relationship->isNullable() && $relationship->getAction() != 'ACTION_CASCADE') {
$parentEntities[] = $relationship->getAlias();
}
}
return $parentEntities;
} | [
"private",
"function",
"getDeletionPreventingParents",
"(",
")",
"{",
"$",
"parentEntities",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getModelBuilder",
"(",
")",
"->",
"getRelationships",
"(",
")",
"as",
"$",
"relationship",
")",
"{",... | Return the parents that prevent deletion
@return array | [
"Return",
"the",
"parents",
"that",
"prevent",
"deletion"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/ControllerBuilder.php#L818-L827 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Params.php | Params.loadParams | private function loadParams() {
if($this->getRequest()->getRawBody() == ''
&& empty($this->getRequest()->getPost())
&& empty($this->getRequest()->getPut())
&& empty($this->getRequest()->getUploadedFiles())
) {
throw new Exception('No Data Passed', 400);
}
$bulkCreation = false;
if(!is_null($this->getRequest()->getJsonRawBody())) {
$params = $this->getRequest()->getJsonRawBody();
$delimiter = '.';
if(is_array($params)) {
$bulkCreation = true;
}
} else {
if($this->getRequest()->isPost()) {
$params = $this->getRequest()->getPost();
} else {
$params = $this->getPut();
}
$delimiter = '_';
}
if($this->request->getRawBody()!='' && sizeOf($params) == 0 && json_last_error() != JSON_ERROR_NONE) {
$this->dispatchJsonError();
}
if($bulkCreation) { //Bulk Creation
$outputParams = [];
foreach($params as $param) {
$helper = new SplitHelper($delimiter);
$outputParams[] = $helper->convert((array)$param);
}
$this->setParams($outputParams);
} else {
$helper = new SplitHelper($delimiter);
$this->setParams($helper->convert((array)$params));
}
} | php | private function loadParams() {
if($this->getRequest()->getRawBody() == ''
&& empty($this->getRequest()->getPost())
&& empty($this->getRequest()->getPut())
&& empty($this->getRequest()->getUploadedFiles())
) {
throw new Exception('No Data Passed', 400);
}
$bulkCreation = false;
if(!is_null($this->getRequest()->getJsonRawBody())) {
$params = $this->getRequest()->getJsonRawBody();
$delimiter = '.';
if(is_array($params)) {
$bulkCreation = true;
}
} else {
if($this->getRequest()->isPost()) {
$params = $this->getRequest()->getPost();
} else {
$params = $this->getPut();
}
$delimiter = '_';
}
if($this->request->getRawBody()!='' && sizeOf($params) == 0 && json_last_error() != JSON_ERROR_NONE) {
$this->dispatchJsonError();
}
if($bulkCreation) { //Bulk Creation
$outputParams = [];
foreach($params as $param) {
$helper = new SplitHelper($delimiter);
$outputParams[] = $helper->convert((array)$param);
}
$this->setParams($outputParams);
} else {
$helper = new SplitHelper($delimiter);
$this->setParams($helper->convert((array)$params));
}
} | [
"private",
"function",
"loadParams",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getRawBody",
"(",
")",
"==",
"''",
"&&",
"empty",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getPost",
"(",
")",
")",
"&&",... | Gets the parameters, sorted from parent to child
@return \stdClass
@throws Exception | [
"Gets",
"the",
"parameters",
"sorted",
"from",
"parent",
"to",
"child"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Params.php#L147-L184 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Database/Transaction.php | Transaction.getTransaction | public function getTransaction() {
if(!$this->isInTransaction()) {
throw new \Exception('This transaction has already been rolled back, or committed, or has not began yet');
}
$transactions = $this->getTransactions();
return $transactions[$this->getDbService()];
} | php | public function getTransaction() {
if(!$this->isInTransaction()) {
throw new \Exception('This transaction has already been rolled back, or committed, or has not began yet');
}
$transactions = $this->getTransactions();
return $transactions[$this->getDbService()];
} | [
"public",
"function",
"getTransaction",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isInTransaction",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'This transaction has already been rolled back, or committed, or has not began yet'",
")",
";",
... | Gets the current transaction, throws an exception if there isn't one
@return TransactionInterface
@throws \Exception | [
"Gets",
"the",
"current",
"transaction",
"throws",
"an",
"exception",
"if",
"there",
"isn",
"t",
"one"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Database/Transaction.php#L114-L120 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Database/Index.php | Index.addColumn | public function addColumn($column) {
$columns = $this->getColumns();
$columns[] = $column;
$this->setColumns($columns);
} | php | public function addColumn($column) {
$columns = $this->getColumns();
$columns[] = $column;
$this->setColumns($columns);
} | [
"public",
"function",
"addColumn",
"(",
"$",
"column",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
")",
";",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
";",
"$",
"this",
"->",
"setColumns",
"(",
"$",
"columns",
")",
";",... | Adds a new column
@param string $column
@return void | [
"Adds",
"a",
"new",
"column"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Database/Index.php#L68-L72 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/PluralHelper.php | PluralHelper.pluralize | public static function pluralize($string) {
$string = trim($string);
$testString = strtolower($string);
if($testString == '') {
return '';
} elseif(substr($testString, -3) == 'day') {
return $string.'s';
} elseif(substr($testString, -2) == 'ch') {
return $string.'es';
} elseif(substr($testString, -1) == 'x') {
return $string.'es';
} elseif(substr($testString, -1) == 'y') {
return substr($string, 0, -1).'ies';
} else {
return $string.'s';
}
} | php | public static function pluralize($string) {
$string = trim($string);
$testString = strtolower($string);
if($testString == '') {
return '';
} elseif(substr($testString, -3) == 'day') {
return $string.'s';
} elseif(substr($testString, -2) == 'ch') {
return $string.'es';
} elseif(substr($testString, -1) == 'x') {
return $string.'es';
} elseif(substr($testString, -1) == 'y') {
return substr($string, 0, -1).'ies';
} else {
return $string.'s';
}
} | [
"public",
"static",
"function",
"pluralize",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"trim",
"(",
"$",
"string",
")",
";",
"$",
"testString",
"=",
"strtolower",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"testString",
"==",
"''",
")",
... | pluralizes a string
@param string $string
@return string | [
"pluralizes",
"a",
"string"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/PluralHelper.php#L13-L29 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/DependencyInjection.php | DependencyInjection.getDi | public function getDi() {
if(is_null($this->di)) {
$this->di = FactoryDefault::getDefault();
if(is_null($this->di)) {
$this->di = new FactoryDefault();
}
}
return $this->di;
} | php | public function getDi() {
if(is_null($this->di)) {
$this->di = FactoryDefault::getDefault();
if(is_null($this->di)) {
$this->di = new FactoryDefault();
}
}
return $this->di;
} | [
"public",
"function",
"getDi",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"di",
")",
")",
"{",
"$",
"this",
"->",
"di",
"=",
"FactoryDefault",
"::",
"getDefault",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"di"... | Gets the dependency injector
@return DiInterface | [
"Gets",
"the",
"dependency",
"injector"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/DependencyInjection.php#L16-L24 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/DataValidation/StrToTime.php | StrToTime.parse | public function parse($date) {
if(is_int($date) || is_double($date) || (is_string($date) && preg_match('@^[0-9]+$@', $date))) {
return (double)$date;
} elseif($date instanceof Date) {
return $date->getEpoch();
} elseif(is_null($date)) {
return false;
} else {
$date = trim(Assert::isString($date));
}
$date = $this->parseHoursMinutes($date);
if(preg_match('@^[0-9]+$@', $date)) {
return (int)$date;
}
$date = $this->stripTimezone($date);
$date = $this->stripRange($date);
if(preg_match('@^(\d{4}-\d{2}-\d{2} )?24:00(:00)?$@', trim($date), $matches)) {
if(isset($matches[1]) && strlen($matches[1]) > 0) {
$date = strtotime($matches[1]);
} else {
$date = time();
}
return mktime(0, 0, 0, date('n', $date), date('j', $date) + 1, date('Y', $date));
}
//change a/p to am/pm
$date = preg_replace('@(^|[^a-z])(a|p)([^a-z]|$)@i', '\\1\\2m\\3', $date);
//Add a colon from 315am,1215 am
$date = preg_replace('@(^|[^0-9])(\d{1,2})(\d{2})\s*(am|pm)@i', '\\1\\2:\\3\\4', $date);
//Fix for dashes instead of slashes
$date = preg_replace('@(\d{2})-(\d{2})-(\d{4})@', '\\1/\\2/\\3', $date);
//Fix for dots instead of slashes
$date = preg_replace('@(\d{2})\.(\d{2})\.(\d{4})@', '\\1/\\2/\\3', $date);
//Fix for UK/euro Version
if(in_array(Formatter::getDefault()->getDateFormat(), array(Formatter::DATE_FORMAT_UK, Formatter::DATE_FORMAT_EURO))) {
//Switch the d/m/Y to the US format m/d/Y to be able to parse
$date = preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\\2/\\1/\\3', $date);
}
switch(strtolower($date)) {
case '9999-12-31':
return 253402232400;
break;
case '0000-00-00':
return 0;
break;
case '0000-00-00 00:00:00':
return 0;
break;
case '24:00:00':
case '24:00':
return mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
break;
case 'thanksgiving':
$firstDay = mktime(0, 0, 0, 11, 1);
$add = 26 - date('w', $firstDay);
if($add < 22) {
$add += 7;
}
return mktime(0, 0, 0, 11, $add);
break;
default:
return strtotime($date);
}
} | php | public function parse($date) {
if(is_int($date) || is_double($date) || (is_string($date) && preg_match('@^[0-9]+$@', $date))) {
return (double)$date;
} elseif($date instanceof Date) {
return $date->getEpoch();
} elseif(is_null($date)) {
return false;
} else {
$date = trim(Assert::isString($date));
}
$date = $this->parseHoursMinutes($date);
if(preg_match('@^[0-9]+$@', $date)) {
return (int)$date;
}
$date = $this->stripTimezone($date);
$date = $this->stripRange($date);
if(preg_match('@^(\d{4}-\d{2}-\d{2} )?24:00(:00)?$@', trim($date), $matches)) {
if(isset($matches[1]) && strlen($matches[1]) > 0) {
$date = strtotime($matches[1]);
} else {
$date = time();
}
return mktime(0, 0, 0, date('n', $date), date('j', $date) + 1, date('Y', $date));
}
//change a/p to am/pm
$date = preg_replace('@(^|[^a-z])(a|p)([^a-z]|$)@i', '\\1\\2m\\3', $date);
//Add a colon from 315am,1215 am
$date = preg_replace('@(^|[^0-9])(\d{1,2})(\d{2})\s*(am|pm)@i', '\\1\\2:\\3\\4', $date);
//Fix for dashes instead of slashes
$date = preg_replace('@(\d{2})-(\d{2})-(\d{4})@', '\\1/\\2/\\3', $date);
//Fix for dots instead of slashes
$date = preg_replace('@(\d{2})\.(\d{2})\.(\d{4})@', '\\1/\\2/\\3', $date);
//Fix for UK/euro Version
if(in_array(Formatter::getDefault()->getDateFormat(), array(Formatter::DATE_FORMAT_UK, Formatter::DATE_FORMAT_EURO))) {
//Switch the d/m/Y to the US format m/d/Y to be able to parse
$date = preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\\2/\\1/\\3', $date);
}
switch(strtolower($date)) {
case '9999-12-31':
return 253402232400;
break;
case '0000-00-00':
return 0;
break;
case '0000-00-00 00:00:00':
return 0;
break;
case '24:00:00':
case '24:00':
return mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
break;
case 'thanksgiving':
$firstDay = mktime(0, 0, 0, 11, 1);
$add = 26 - date('w', $firstDay);
if($add < 22) {
$add += 7;
}
return mktime(0, 0, 0, 11, $add);
break;
default:
return strtotime($date);
}
} | [
"public",
"function",
"parse",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"date",
")",
"||",
"is_double",
"(",
"$",
"date",
")",
"||",
"(",
"is_string",
"(",
"$",
"date",
")",
"&&",
"preg_match",
"(",
"'@^[0-9]+$@'",
",",
"$",
"date... | Converts a string of any date to a timestamp
@param int|string|Date $date
@throws InvalidArgumentException
@return int | [
"Converts",
"a",
"string",
"of",
"any",
"date",
"to",
"a",
"timestamp"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/DataValidation/StrToTime.php#L16-L82 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Swagger/Operation.php | Operation.addResponseMessage | public function addResponseMessage(ResponseMessage $responseMessage) {
$responseMessages = $this->getResponseMessages();
$responseMessages[] = $responseMessage;
$this->setResponseMessages($responseMessages);
} | php | public function addResponseMessage(ResponseMessage $responseMessage) {
$responseMessages = $this->getResponseMessages();
$responseMessages[] = $responseMessage;
$this->setResponseMessages($responseMessages);
} | [
"public",
"function",
"addResponseMessage",
"(",
"ResponseMessage",
"$",
"responseMessage",
")",
"{",
"$",
"responseMessages",
"=",
"$",
"this",
"->",
"getResponseMessages",
"(",
")",
";",
"$",
"responseMessages",
"[",
"]",
"=",
"$",
"responseMessage",
";",
"$",... | Adds new responseMessage
@param ResponseMessage $responseMessage
@return void | [
"Adds",
"new",
"responseMessage"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Swagger/Operation.php#L88-L92 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Swagger/Model.php | Model.addProperty | public function addProperty(Property $property) {
$properties = $this->getProperties();
$properties[] = $property;
$this->setProperties($properties);
} | php | public function addProperty(Property $property) {
$properties = $this->getProperties();
$properties[] = $property;
$this->setProperties($properties);
} | [
"public",
"function",
"addProperty",
"(",
"Property",
"$",
"property",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"$",
"properties",
"[",
"]",
"=",
"$",
"property",
";",
"$",
"this",
"->",
"setProperties",
"(",
... | Adds new property
@param Property $property
@return void | [
"Adds",
"new",
"property"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Swagger/Model.php#L17-L21 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/DataValidation/Assert.php | Assert.isBool | public static function isBool($input) {
if(is_bool($input)) {
return $input; //Already a boolean
}
if(is_int($input) || is_float($input)) {
return $input != 0;
}
$input = strtolower(self::isString($input));
return in_array($input, array('active', 'true', 'yes', '1', 'on', 'y'), TRUE);
} | php | public static function isBool($input) {
if(is_bool($input)) {
return $input; //Already a boolean
}
if(is_int($input) || is_float($input)) {
return $input != 0;
}
$input = strtolower(self::isString($input));
return in_array($input, array('active', 'true', 'yes', '1', 'on', 'y'), TRUE);
} | [
"public",
"static",
"function",
"isBool",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"input",
";",
"//Already a boolean",
"}",
"if",
"(",
"is_int",
"(",
"$",
"input",
")",
"||",
"is_float",
"("... | Cleans bool input
@param string $input
@return bool | [
"Cleans",
"bool",
"input"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/DataValidation/Assert.php#L10-L19 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.validateServicesDefined | private function validateServicesDefined() {
if(!$this->getDi()->has(AclInterface::DI_NAME)) {
throw new \Exception('Service ' . AclInterface::class . '::DI_NAME must be defined with a type of: ' . AclInterface::class);
}
if(!$this->getDi()->has(OutputInterface::DI_NAME)) {
throw new \Exception('Service ' . OutputInterface::class . '::DI_NAME must be defined with a type of: ' . OutputInterface::class);
}
} | php | private function validateServicesDefined() {
if(!$this->getDi()->has(AclInterface::DI_NAME)) {
throw new \Exception('Service ' . AclInterface::class . '::DI_NAME must be defined with a type of: ' . AclInterface::class);
}
if(!$this->getDi()->has(OutputInterface::DI_NAME)) {
throw new \Exception('Service ' . OutputInterface::class . '::DI_NAME must be defined with a type of: ' . OutputInterface::class);
}
} | [
"private",
"function",
"validateServicesDefined",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getDi",
"(",
")",
"->",
"has",
"(",
"AclInterface",
"::",
"DI_NAME",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Service '",
".",
"AclInterf... | Validates to make sure all required services are defined
@return void
@throws \Exception | [
"Validates",
"to",
"make",
"sure",
"all",
"required",
"services",
"are",
"defined"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L62-L69 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.indexAction | protected function indexAction() {
try {
$entity = $this->generateEntity();
$query = new Index($this->request, $entity, $this->getQueryWhiteList());
$this->response->setHeader('link', $query->generateLinks());
/** @var ResultSet|ModelInterface[] $entities */
$entities = $query->getResultSet();
$entities = $this->filterEntities($entities);
$this->indexActionInternal($entities);
if($this->hasFlag((new FlagEnum(FlagEnum::PAGE_COUNTS)))) {
$this->getOutputObject()->PageCounts = $query->generatePageCounts();
}
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
} catch(CatchableException $e) {
$this->handleCatchableError($e);
}
} | php | protected function indexAction() {
try {
$entity = $this->generateEntity();
$query = new Index($this->request, $entity, $this->getQueryWhiteList());
$this->response->setHeader('link', $query->generateLinks());
/** @var ResultSet|ModelInterface[] $entities */
$entities = $query->getResultSet();
$entities = $this->filterEntities($entities);
$this->indexActionInternal($entities);
if($this->hasFlag((new FlagEnum(FlagEnum::PAGE_COUNTS)))) {
$this->getOutputObject()->PageCounts = $query->generatePageCounts();
}
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
} catch(CatchableException $e) {
$this->handleCatchableError($e);
}
} | [
"protected",
"function",
"indexAction",
"(",
")",
"{",
"try",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"generateEntity",
"(",
")",
";",
"$",
"query",
"=",
"new",
"Index",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"entity",
",",
"$",
"this",
"... | This provides a list of the entities
@return void | [
"This",
"provides",
"a",
"list",
"of",
"the",
"entities"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L173-L195 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.optionsAction | public function optionsAction() {
$this->response->setHeader('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, OPTIONS');
$allowedHeaders = array_merge(
['X-Requested-With', 'X-HTTP-Method-Override', 'Content-Type', 'Accept', 'Cache-Control'],
$this->getExtraAllowedHeaders()
);
$this->response->setHeader('Access-Control-Allow-Headers', implode(', ', $allowedHeaders));
$this->setStatusCode(200);
} | php | public function optionsAction() {
$this->response->setHeader('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, OPTIONS');
$allowedHeaders = array_merge(
['X-Requested-With', 'X-HTTP-Method-Override', 'Content-Type', 'Accept', 'Cache-Control'],
$this->getExtraAllowedHeaders()
);
$this->response->setHeader('Access-Control-Allow-Headers', implode(', ', $allowedHeaders));
$this->setStatusCode(200);
} | [
"public",
"function",
"optionsAction",
"(",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"setHeader",
"(",
"'Access-Control-Allow-Methods'",
",",
"'POST, GET, PUT, DELETE, OPTIONS'",
")",
";",
"$",
"allowedHeaders",
"=",
"array_merge",
"(",
"[",
"'X-Requested-With'"... | Needed for CORs
@return void | [
"Needed",
"for",
"CORs"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L220-L228 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.createActionProcess | private function createActionProcess() {
/** @var CreateObject[] $createObjects */
$createObjects = [];
try {
$params = new Params($this->request);
} catch(Exception $e) {
$this->handleError($e);
return $createObjects;
}
$postParams = $params->getParams();
if(!is_array($postParams)) {
$postParams = [$postParams];
}
foreach($postParams as $postParam) {
$createObject = new CreateObject($postParam);
try {
$entity = $this->createActionInternal($postParam);
$createObject->setEntity($entity);
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
} catch(CatchableException $e) {
$this->handleCatchableError($e);
}
$createObject->setStatusCode($this->getStatusCode());
$createObject->setErrors($this->getErrors());
$this->setErrors([]);
$createObjects[] = $createObject;
}
return $createObjects;
} | php | private function createActionProcess() {
/** @var CreateObject[] $createObjects */
$createObjects = [];
try {
$params = new Params($this->request);
} catch(Exception $e) {
$this->handleError($e);
return $createObjects;
}
$postParams = $params->getParams();
if(!is_array($postParams)) {
$postParams = [$postParams];
}
foreach($postParams as $postParam) {
$createObject = new CreateObject($postParam);
try {
$entity = $this->createActionInternal($postParam);
$createObject->setEntity($entity);
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
} catch(CatchableException $e) {
$this->handleCatchableError($e);
}
$createObject->setStatusCode($this->getStatusCode());
$createObject->setErrors($this->getErrors());
$this->setErrors([]);
$createObjects[] = $createObject;
}
return $createObjects;
} | [
"private",
"function",
"createActionProcess",
"(",
")",
"{",
"/** @var CreateObject[] $createObjects */",
"$",
"createObjects",
"=",
"[",
"]",
";",
"try",
"{",
"$",
"params",
"=",
"new",
"Params",
"(",
"$",
"this",
"->",
"request",
")",
";",
"}",
"catch",
"(... | Creates the entities, returns a list of createObjects, to process accordingly
@return \Bullhorn\FastRest\Api\Models\CreateObject[] | [
"Creates",
"the",
"entities",
"returns",
"a",
"list",
"of",
"createObjects",
"to",
"process",
"accordingly"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L296-L330 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.createActionInternal | private function createActionInternal(\stdClass $postParams) {
$entity = $this->generateEntity();
$this->saveEntity($postParams, $entity, true);
// since our entity can be manipulated after saving, we need to find it again, just in case.
/** @var ModelInterface $newEntity */
$newEntity = $entity->findFirst($entity->getId());
//Fix if there are two entities created (with bulk insert), and the first fails, but the second succeeds, the second with get the first's errors
$reflectionClass = new \ReflectionClass($newEntity);
$reflectionProperty = $reflectionClass->getProperty('_errorMessages');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($newEntity, []);
return $newEntity;
} | php | private function createActionInternal(\stdClass $postParams) {
$entity = $this->generateEntity();
$this->saveEntity($postParams, $entity, true);
// since our entity can be manipulated after saving, we need to find it again, just in case.
/** @var ModelInterface $newEntity */
$newEntity = $entity->findFirst($entity->getId());
//Fix if there are two entities created (with bulk insert), and the first fails, but the second succeeds, the second with get the first's errors
$reflectionClass = new \ReflectionClass($newEntity);
$reflectionProperty = $reflectionClass->getProperty('_errorMessages');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($newEntity, []);
return $newEntity;
} | [
"private",
"function",
"createActionInternal",
"(",
"\\",
"stdClass",
"$",
"postParams",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"generateEntity",
"(",
")",
";",
"$",
"this",
"->",
"saveEntity",
"(",
"$",
"postParams",
",",
"$",
"entity",
",",
"... | Provides the actual creating of a new entity.
@param \stdClass $postParams
@return ModelInterface | [
"Provides",
"the",
"actual",
"creating",
"of",
"a",
"new",
"entity",
"."
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L337-L349 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.showActionInternal | protected function showActionInternal(ModelInterface $entity) {
$outputObject = $this->getOutputObject();
$outputObject->{$entity->getEntityName()} = $this->generateEntityAction($entity);
$this->setOutputObject($outputObject);
} | php | protected function showActionInternal(ModelInterface $entity) {
$outputObject = $this->getOutputObject();
$outputObject->{$entity->getEntityName()} = $this->generateEntityAction($entity);
$this->setOutputObject($outputObject);
} | [
"protected",
"function",
"showActionInternal",
"(",
"ModelInterface",
"$",
"entity",
")",
"{",
"$",
"outputObject",
"=",
"$",
"this",
"->",
"getOutputObject",
"(",
")",
";",
"$",
"outputObject",
"->",
"{",
"$",
"entity",
"->",
"getEntityName",
"(",
")",
"}",... | Looks up an individual entity
@param ModelInterface $entity
@return void | [
"Looks",
"up",
"an",
"individual",
"entity"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L426-L430 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.generateEntityAction | private function generateEntityAction(ModelInterface $entity) {
session_write_close();
$show = new Show($entity);
$showCriteria = new ShowCriteria($this->request);
return $show->generate($showCriteria->getField());
} | php | private function generateEntityAction(ModelInterface $entity) {
session_write_close();
$show = new Show($entity);
$showCriteria = new ShowCriteria($this->request);
return $show->generate($showCriteria->getField());
} | [
"private",
"function",
"generateEntityAction",
"(",
"ModelInterface",
"$",
"entity",
")",
"{",
"session_write_close",
"(",
")",
";",
"$",
"show",
"=",
"new",
"Show",
"(",
"$",
"entity",
")",
";",
"$",
"showCriteria",
"=",
"new",
"ShowCriteria",
"(",
"$",
"... | Generates the output of an entity
@param ModelInterface $entity
@return \stdClass | [
"Generates",
"the",
"output",
"of",
"an",
"entity"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L439-L444 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.findPostParams | private function findPostParams(\stdClass $postParams, ModelInterface $entity) {
//Entity is passed in so children can access it
$dataTransformer = $this->getDataTransformer($postParams);
if(!is_null($dataTransformer)) {
$dataTransformer->transform($entity);
$postParams = $dataTransformer->getParams();
}
return $postParams;
} | php | private function findPostParams(\stdClass $postParams, ModelInterface $entity) {
//Entity is passed in so children can access it
$dataTransformer = $this->getDataTransformer($postParams);
if(!is_null($dataTransformer)) {
$dataTransformer->transform($entity);
$postParams = $dataTransformer->getParams();
}
return $postParams;
} | [
"private",
"function",
"findPostParams",
"(",
"\\",
"stdClass",
"$",
"postParams",
",",
"ModelInterface",
"$",
"entity",
")",
"{",
"//Entity is passed in so children can access it",
"$",
"dataTransformer",
"=",
"$",
"this",
"->",
"getDataTransformer",
"(",
"$",
"postP... | Finds the post parameters
@param \stdClass $postParams
@param ModelInterface $entity
@return \stdClass | [
"Finds",
"the",
"post",
"parameters"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L506-L514 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.deleteAction | public function deleteAction() {
try {
if(sizeOf($this->dispatcher->getParams()) == 0) {
throw new Exception('Invalid Entity Id Passed In', 400);
}
$entity = $this->validateEntityId($this->dispatcher->getParam(0));
$this->deleteActionInternal($entity);
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
}
} | php | public function deleteAction() {
try {
if(sizeOf($this->dispatcher->getParams()) == 0) {
throw new Exception('Invalid Entity Id Passed In', 400);
}
$entity = $this->validateEntityId($this->dispatcher->getParam(0));
$this->deleteActionInternal($entity);
} catch(Exception $e) {
$this->handleError($e);
} catch(ValidationException $e) {
$this->handleValidationError($e);
} catch(AclException $e) {
$this->handleAclError($e);
}
} | [
"public",
"function",
"deleteAction",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"sizeOf",
"(",
"$",
"this",
"->",
"dispatcher",
"->",
"getParams",
"(",
")",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid Entity Id Passed In'",
",",
"40... | Deletes an individual entity
@return void | [
"Deletes",
"an",
"individual",
"entity"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L540-L554 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.getAcl | public function getAcl() {
$returnVar = $this->getDi()->get(AclInterface::DI_NAME);
if(!($returnVar instanceof AclInterface)) {
throw new \Exception('The Acl must implement: ' . AclInterface::class);
}
return $returnVar;
} | php | public function getAcl() {
$returnVar = $this->getDi()->get(AclInterface::DI_NAME);
if(!($returnVar instanceof AclInterface)) {
throw new \Exception('The Acl must implement: ' . AclInterface::class);
}
return $returnVar;
} | [
"public",
"function",
"getAcl",
"(",
")",
"{",
"$",
"returnVar",
"=",
"$",
"this",
"->",
"getDi",
"(",
")",
"->",
"get",
"(",
"AclInterface",
"::",
"DI_NAME",
")",
";",
"if",
"(",
"!",
"(",
"$",
"returnVar",
"instanceof",
"AclInterface",
")",
")",
"{... | Gets the Access Control Layer
@return AclInterface
@throws \Exception | [
"Gets",
"the",
"Access",
"Control",
"Layer"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L561-L567 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.deleteActionInternal | protected function deleteActionInternal(ModelInterface $entity) {
$this->setStatusCode(204);
$delete = new Delete($entity);
$delete->process($this->getAcl());
} | php | protected function deleteActionInternal(ModelInterface $entity) {
$this->setStatusCode(204);
$delete = new Delete($entity);
$delete->process($this->getAcl());
} | [
"protected",
"function",
"deleteActionInternal",
"(",
"ModelInterface",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"setStatusCode",
"(",
"204",
")",
";",
"$",
"delete",
"=",
"new",
"Delete",
"(",
"$",
"entity",
")",
";",
"$",
"delete",
"->",
"process",
... | Default delete action for our entities.
@param ModelInterface $entity
@return void | [
"Default",
"delete",
"action",
"for",
"our",
"entities",
"."
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L576-L580 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.lookUpEntity | protected function lookUpEntity($entityId) {
$entity = $this->generateEntity();
$entityInstance = $entity->findFirst($entityId);
if($entityInstance === false) {
throw new Exception("Invalid Entity Id: Entity not found.", 404);
}
return $entityInstance;
} | php | protected function lookUpEntity($entityId) {
$entity = $this->generateEntity();
$entityInstance = $entity->findFirst($entityId);
if($entityInstance === false) {
throw new Exception("Invalid Entity Id: Entity not found.", 404);
}
return $entityInstance;
} | [
"protected",
"function",
"lookUpEntity",
"(",
"$",
"entityId",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"generateEntity",
"(",
")",
";",
"$",
"entityInstance",
"=",
"$",
"entity",
"->",
"findFirst",
"(",
"$",
"entityId",
")",
";",
"if",
"(",
"$... | This looks up an entity based off of the entity id
@param int $entityId
@throws Exception - If unable to find the entity, return a 404 to the user.
@return ModelInterface | [
"This",
"looks",
"up",
"an",
"entity",
"based",
"off",
"of",
"the",
"entity",
"id"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L606-L613 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.afterExecuteRoute | public function afterExecuteRoute() {
/** @var \Bullhorn\FastRest\Api\Services\Output\OutputInterface $output */
$output = $this->getDI()->get(OutputInterface::DI_NAME);
if(!($output instanceof OutputInterface)) {
throw new \Exception('The Output must implement: ' . OutputInterface::class);
}
$object = $this->getOutputObject();
$errors = $this->getErrors();
$code = $this->getStatusCode();
$object = $this->addErrorsAndStatus($errors, $code, $object);
$this->response->setStatusCode($object->statusCode, 'Check Document Body For More Details');
$output->output($object, $this->response);
$this->view->disable();
} | php | public function afterExecuteRoute() {
/** @var \Bullhorn\FastRest\Api\Services\Output\OutputInterface $output */
$output = $this->getDI()->get(OutputInterface::DI_NAME);
if(!($output instanceof OutputInterface)) {
throw new \Exception('The Output must implement: ' . OutputInterface::class);
}
$object = $this->getOutputObject();
$errors = $this->getErrors();
$code = $this->getStatusCode();
$object = $this->addErrorsAndStatus($errors, $code, $object);
$this->response->setStatusCode($object->statusCode, 'Check Document Body For More Details');
$output->output($object, $this->response);
$this->view->disable();
} | [
"public",
"function",
"afterExecuteRoute",
"(",
")",
"{",
"/** @var \\Bullhorn\\FastRest\\Api\\Services\\Output\\OutputInterface $output */",
"$",
"output",
"=",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"get",
"(",
"OutputInterface",
"::",
"DI_NAME",
")",
";",
"if"... | Executed after it is routed
@return void
@throws \Exception | [
"Executed",
"after",
"it",
"is",
"routed"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L622-L636 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.handleValidationError | protected function handleValidationError(ValidationException $e, $errorCode = 409) {
$entity = $e->getEntity();
foreach($entity->getMessages() as $message) {
$this->addError(new Exception($message->getMessage(), $errorCode));
}
} | php | protected function handleValidationError(ValidationException $e, $errorCode = 409) {
$entity = $e->getEntity();
foreach($entity->getMessages() as $message) {
$this->addError(new Exception($message->getMessage(), $errorCode));
}
} | [
"protected",
"function",
"handleValidationError",
"(",
"ValidationException",
"$",
"e",
",",
"$",
"errorCode",
"=",
"409",
")",
"{",
"$",
"entity",
"=",
"$",
"e",
"->",
"getEntity",
"(",
")",
";",
"foreach",
"(",
"$",
"entity",
"->",
"getMessages",
"(",
... | Handles exceptions from validations
@param ValidationException $e
@param int $errorCode
@return void | [
"Handles",
"exceptions",
"from",
"validations"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L688-L693 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Controllers/Base.php | Base.handleAclError | protected function handleAclError(AclException $e) {
if(!empty($e->getMessage())) {
$this->addError(new Exception($e->getMessage(), 401));
}
$entity = $e->getEntity();
if(!is_null($entity)) {
foreach ($entity->getMessages() as $message) {
$this->addError(new Exception($message->getMessage(), 401));
}
}
} | php | protected function handleAclError(AclException $e) {
if(!empty($e->getMessage())) {
$this->addError(new Exception($e->getMessage(), 401));
}
$entity = $e->getEntity();
if(!is_null($entity)) {
foreach ($entity->getMessages() as $message) {
$this->addError(new Exception($message->getMessage(), 401));
}
}
} | [
"protected",
"function",
"handleAclError",
"(",
"AclException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"new",
"Exception",
"(",
"$",
"e",
"->",
"g... | Handles exceptions from acl
@param AclException $e
@return void | [
"Handles",
"exceptions",
"from",
"acl"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Controllers/Base.php#L702-L712 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Database/Field.php | Field.getShortName | public function getShortName() {
$name = $this->getName();
//Strip out the table name
if(substr($name, 0, strlen($this->getTableName())) == $this->getTableName() && lcfirst(substr($name, strlen($this->getTableName()))) != 'source') {
$name = lcfirst(substr($name, strlen($this->getTableName())));
}
return $name;
} | php | public function getShortName() {
$name = $this->getName();
//Strip out the table name
if(substr($name, 0, strlen($this->getTableName())) == $this->getTableName() && lcfirst(substr($name, strlen($this->getTableName()))) != 'source') {
$name = lcfirst(substr($name, strlen($this->getTableName())));
}
return $name;
} | [
"public",
"function",
"getShortName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"//Strip out the table name",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"getTableName",
"(... | Gets the name without the table name
@return string | [
"Gets",
"the",
"name",
"without",
"the",
"table",
"name"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Database/Field.php#L255-L262 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php | Show.generate | public function generate(Field $field) {
$output = new \stdClass();
$this->showRecursive($output, $field, $this->getEntity());
return $output;
} | php | public function generate(Field $field) {
$output = new \stdClass();
$this->showRecursive($output, $field, $this->getEntity());
return $output;
} | [
"public",
"function",
"generate",
"(",
"Field",
"$",
"field",
")",
"{",
"$",
"output",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"this",
"->",
"showRecursive",
"(",
"$",
"output",
",",
"$",
"field",
",",
"$",
"this",
"->",
"getEntity",
"(",
... | Generates the std object to show
@param Field $field
@return \stdClass | [
"Generates",
"the",
"std",
"object",
"to",
"show"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php#L24-L28 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php | Show.showRecursive | private function showRecursive(\stdClass $output, Field $field, ApiInterface $entity) {
$this->getAcl()->canRead($entity);
$columns = $entity->getModelsMetaData()->getColumnMap($entity);
$columns = array_merge($columns, $entity->getExtraProperties());
foreach($field->getChildren() as $child) {
$this->showParentsAndChildren(
$output,
$entity,
$child
);
}
foreach($field->getFields() as $subField) {
if($subField == '*') { //All parts
$lazyProperties = $entity->getLazyProperties();
foreach(array_diff($columns, $lazyProperties) as $column) {
$this->showField($output, $entity, $column);
}
} elseif(in_array($subField, $columns)) {
$this->showField($output, $entity, $subField);
} elseif(in_array($subField, $entity->getChildrenRelationships()) || in_array($subField, $entity->getParentRelationships())) {
throw new Exception('Invalid Field, child or parent: ' . $entity->getEntityName() . ' with "' . $subField . '". Please add .* to the end to get all related fields', 400);
} else {
throw new Exception('Invalid Field, not on the current object: ' . $entity->getEntityName() . ' with ' . $subField, 400);
}
}
} | php | private function showRecursive(\stdClass $output, Field $field, ApiInterface $entity) {
$this->getAcl()->canRead($entity);
$columns = $entity->getModelsMetaData()->getColumnMap($entity);
$columns = array_merge($columns, $entity->getExtraProperties());
foreach($field->getChildren() as $child) {
$this->showParentsAndChildren(
$output,
$entity,
$child
);
}
foreach($field->getFields() as $subField) {
if($subField == '*') { //All parts
$lazyProperties = $entity->getLazyProperties();
foreach(array_diff($columns, $lazyProperties) as $column) {
$this->showField($output, $entity, $column);
}
} elseif(in_array($subField, $columns)) {
$this->showField($output, $entity, $subField);
} elseif(in_array($subField, $entity->getChildrenRelationships()) || in_array($subField, $entity->getParentRelationships())) {
throw new Exception('Invalid Field, child or parent: ' . $entity->getEntityName() . ' with "' . $subField . '". Please add .* to the end to get all related fields', 400);
} else {
throw new Exception('Invalid Field, not on the current object: ' . $entity->getEntityName() . ' with ' . $subField, 400);
}
}
} | [
"private",
"function",
"showRecursive",
"(",
"\\",
"stdClass",
"$",
"output",
",",
"Field",
"$",
"field",
",",
"ApiInterface",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"getAcl",
"(",
")",
"->",
"canRead",
"(",
"$",
"entity",
")",
";",
"$",
"columns"... | Adds to the output object the specified field
@param \stdClass $output
@param Field $field
@param ApiInterface $entity
@return void
@throws Exception | [
"Adds",
"to",
"the",
"output",
"object",
"the",
"specified",
"field"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php#L81-L106 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php | Show.showField | private function showField(\stdClass $output, ApiInterface $entity, $column) {
if($this->getAcl()->canReadField($entity, $column)) {
if(in_array($column, $entity->getUnReadableFields())) {
$value = null;
} else {
$value = $entity->readAttribute($column);
//Fix for Date and DateTime
if(is_object($value) && method_exists($value, '__toString')) {
$value = $value->__toString();
}
}
$output->{$column} = $value;
}
} | php | private function showField(\stdClass $output, ApiInterface $entity, $column) {
if($this->getAcl()->canReadField($entity, $column)) {
if(in_array($column, $entity->getUnReadableFields())) {
$value = null;
} else {
$value = $entity->readAttribute($column);
//Fix for Date and DateTime
if(is_object($value) && method_exists($value, '__toString')) {
$value = $value->__toString();
}
}
$output->{$column} = $value;
}
} | [
"private",
"function",
"showField",
"(",
"\\",
"stdClass",
"$",
"output",
",",
"ApiInterface",
"$",
"entity",
",",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAcl",
"(",
")",
"->",
"canReadField",
"(",
"$",
"entity",
",",
"$",
"column",
... | Shows an individual field
@param \stdClass $output
@param ApiInterface $entity
@param string $column
@return void | [
"Shows",
"an",
"individual",
"field"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Show.php#L117-L130 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Database/Relationship.php | Relationship.getAlias | public function getAlias() {
//Check and see if there is another relationship with the same name
$multipleFound = false;
foreach($this->getRelationships() as $relationship) {
if($relationship !== $this && $relationship->getRemoteTable() == $this->getRemoteTable()) {
$multipleFound = true;
}
}
$returnVar = '';
if($multipleFound) {
if($this->isPlural()) {
$name = $this->getRemoteColumn();
//Strip out local table
if(stripos($name, $this->getRemoteTable()) === 0) {
$name = substr($name, strlen($this->getRemoteTable()));
}
//Strip out remote table name, with id
if(stripos(substr($name, strlen($this->getLocalTable() . 'Id') * -1), $this->getLocalTable() . 'Id') === 0) {
$name = substr($name, 0, strlen($this->getLocalTable() . 'Id') * -1);
}
} else {
$name = $this->getLocalColumn();
//Strip out local table
if(stripos($name, $this->getLocalTable()) === 0) {
$name = substr($name, strlen($this->getLocalTable()));
}
//Strip out remote table name, with id
if(stripos(substr($name, strlen($this->getRemoteTable() . 'Id') * -1), $this->getRemoteTable() . 'Id') === 0) {
$name = substr($name, 0, strlen($this->getRemoteTable() . 'Id') * -1);
}
}
$returnVar .= $name;
}
$returnVar .= $this->getRemoteShortModel();
if($this->isPlural()) {
$pluralHelper = new PluralHelper();
$returnVar = $pluralHelper->pluralize($returnVar);
}
return ucfirst($returnVar);
} | php | public function getAlias() {
//Check and see if there is another relationship with the same name
$multipleFound = false;
foreach($this->getRelationships() as $relationship) {
if($relationship !== $this && $relationship->getRemoteTable() == $this->getRemoteTable()) {
$multipleFound = true;
}
}
$returnVar = '';
if($multipleFound) {
if($this->isPlural()) {
$name = $this->getRemoteColumn();
//Strip out local table
if(stripos($name, $this->getRemoteTable()) === 0) {
$name = substr($name, strlen($this->getRemoteTable()));
}
//Strip out remote table name, with id
if(stripos(substr($name, strlen($this->getLocalTable() . 'Id') * -1), $this->getLocalTable() . 'Id') === 0) {
$name = substr($name, 0, strlen($this->getLocalTable() . 'Id') * -1);
}
} else {
$name = $this->getLocalColumn();
//Strip out local table
if(stripos($name, $this->getLocalTable()) === 0) {
$name = substr($name, strlen($this->getLocalTable()));
}
//Strip out remote table name, with id
if(stripos(substr($name, strlen($this->getRemoteTable() . 'Id') * -1), $this->getRemoteTable() . 'Id') === 0) {
$name = substr($name, 0, strlen($this->getRemoteTable() . 'Id') * -1);
}
}
$returnVar .= $name;
}
$returnVar .= $this->getRemoteShortModel();
if($this->isPlural()) {
$pluralHelper = new PluralHelper();
$returnVar = $pluralHelper->pluralize($returnVar);
}
return ucfirst($returnVar);
} | [
"public",
"function",
"getAlias",
"(",
")",
"{",
"//Check and see if there is another relationship with the same name",
"$",
"multipleFound",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRelationships",
"(",
")",
"as",
"$",
"relationship",
")",
"{",
"if... | Gets the alias
@return string | [
"Gets",
"the",
"alias"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Database/Relationship.php#L121-L160 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Database/Relationship.php | Relationship.getRemoteShortColumn | public function getRemoteShortColumn() {
$name = $this->getRemoteColumn();
//Strip out the table name
if(substr($name, 0, strlen($this->getRemoteTable())) == $this->getRemoteTable() && lcfirst(substr($name, strlen($this->getRemoteTable()))) != 'source') {
$name = lcfirst(substr($name, strlen($this->getRemoteTable())));
}
return $name;
} | php | public function getRemoteShortColumn() {
$name = $this->getRemoteColumn();
//Strip out the table name
if(substr($name, 0, strlen($this->getRemoteTable())) == $this->getRemoteTable() && lcfirst(substr($name, strlen($this->getRemoteTable()))) != 'source') {
$name = lcfirst(substr($name, strlen($this->getRemoteTable())));
}
return $name;
} | [
"public",
"function",
"getRemoteShortColumn",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getRemoteColumn",
"(",
")",
";",
"//Strip out the table name",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"get... | Gets the shortened version of a column
@return string | [
"Gets",
"the",
"shortened",
"version",
"of",
"a",
"column"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Database/Relationship.php#L223-L230 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Database/CriteriaHelper.php | CriteriaHelper.andWhere | public function andWhere($conditions, array $bindParams = null, array $bindTypes = null) {
if(!is_null($bindParams)) {
$tmpBindParams = array();
foreach($bindParams as $key => $value) {
if(is_int($key)) {
$param = 'criteriaHelper' . $this->incrementLocalParamCount();
$tmpBindParams[$param] = $value;
$conditions = str_replace('?' . $key, ':' . $param . ':', $conditions);
} else {
$tmpBindParams[$key] = $value;
}
}
$bindParams = $tmpBindParams;
}
$this->getCriteria()->andWhere($conditions, $bindParams, $bindTypes);
return $this;
} | php | public function andWhere($conditions, array $bindParams = null, array $bindTypes = null) {
if(!is_null($bindParams)) {
$tmpBindParams = array();
foreach($bindParams as $key => $value) {
if(is_int($key)) {
$param = 'criteriaHelper' . $this->incrementLocalParamCount();
$tmpBindParams[$param] = $value;
$conditions = str_replace('?' . $key, ':' . $param . ':', $conditions);
} else {
$tmpBindParams[$key] = $value;
}
}
$bindParams = $tmpBindParams;
}
$this->getCriteria()->andWhere($conditions, $bindParams, $bindTypes);
return $this;
} | [
"public",
"function",
"andWhere",
"(",
"$",
"conditions",
",",
"array",
"$",
"bindParams",
"=",
"null",
",",
"array",
"$",
"bindTypes",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"bindParams",
")",
")",
"{",
"$",
"tmpBindParams",
"=",
... | Appends a condition to the current conditions using an AND operator
@param string $conditions
@param array $bindParams
@param array $bindTypes
@return $this | [
"Appends",
"a",
"condition",
"to",
"the",
"current",
"conditions",
"using",
"an",
"AND",
"operator"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Database/CriteriaHelper.php#L120-L136 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Database/CriteriaHelper.php | CriteriaHelper.execute | public function execute() {
$modelName = $this->getCriteria()->getModelName();
$params = $this->getCriteria()->getParams();
if(!empty($this->getGroupBys())) {
$params['group'] = $this->getGroupBys();
}
return $modelName::find($params);
} | php | public function execute() {
$modelName = $this->getCriteria()->getModelName();
$params = $this->getCriteria()->getParams();
if(!empty($this->getGroupBys())) {
$params['group'] = $this->getGroupBys();
}
return $modelName::find($params);
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"modelName",
"=",
"$",
"this",
"->",
"getCriteria",
"(",
")",
"->",
"getModelName",
"(",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"getCriteria",
"(",
")",
"->",
"getParams",
"(",
")",
";",
... | Executes a find using the parameters built with the criteria
@return ResultSet|Row[] | [
"Executes",
"a",
"find",
"using",
"the",
"parameters",
"built",
"with",
"the",
"criteria"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Database/CriteriaHelper.php#L142-L149 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Formatter.php | Formatter.setCurrentFormat | public function setCurrentFormat($currentFormat) {
$allowedFormats = $this->getAllowedFormats();
if(!in_array($currentFormat, $allowedFormats)) {
throw new InvalidArgumentException('Invalid Date Format: ' . $currentFormat . ', expected: ' . implode(', ', $allowedFormats));
}
$allFormats = $this->getPreviousFormats();
$allFormats[] = $this->getCurrentFormat();
$this->setPreviousFormats($allFormats);
$this->currentFormat = $currentFormat;
} | php | public function setCurrentFormat($currentFormat) {
$allowedFormats = $this->getAllowedFormats();
if(!in_array($currentFormat, $allowedFormats)) {
throw new InvalidArgumentException('Invalid Date Format: ' . $currentFormat . ', expected: ' . implode(', ', $allowedFormats));
}
$allFormats = $this->getPreviousFormats();
$allFormats[] = $this->getCurrentFormat();
$this->setPreviousFormats($allFormats);
$this->currentFormat = $currentFormat;
} | [
"public",
"function",
"setCurrentFormat",
"(",
"$",
"currentFormat",
")",
"{",
"$",
"allowedFormats",
"=",
"$",
"this",
"->",
"getAllowedFormats",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"currentFormat",
",",
"$",
"allowedFormats",
")",
")",
"... | Sets the current format
@param string $currentFormat | [
"Sets",
"the",
"current",
"format"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Formatter.php#L152-L163 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Formatter.php | Formatter.revertFormat | public function revertFormat() {
$allFormats = $this->getPreviousFormats();
if(!empty($allFormats)) {
$this->currentFormat = array_pop($allFormats);
$this->setPreviousFormats($allFormats);
}
} | php | public function revertFormat() {
$allFormats = $this->getPreviousFormats();
if(!empty($allFormats)) {
$this->currentFormat = array_pop($allFormats);
$this->setPreviousFormats($allFormats);
}
} | [
"public",
"function",
"revertFormat",
"(",
")",
"{",
"$",
"allFormats",
"=",
"$",
"this",
"->",
"getPreviousFormats",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"allFormats",
")",
")",
"{",
"$",
"this",
"->",
"currentFormat",
"=",
"array_pop",
"... | reverts to the previous format, does nothing if there are no previous formats
@return void | [
"reverts",
"to",
"the",
"previous",
"format",
"does",
"nothing",
"if",
"there",
"are",
"no",
"previous",
"formats"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Formatter.php#L217-L223 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.initialize | public function initialize() {
$this->keepSnapshots(true);
$this->setup(
array(
'exceptionOnFailedSave' => true, //Throw an exception instead of returning false from saves
'notNullValidations' => false //Allow empty strings instead of the wtf new \Phalcon\Db\RawValue('""');
)
);
//Sets to only update the fields that are changed
$this->useDynamicUpdate(true);
} | php | public function initialize() {
$this->keepSnapshots(true);
$this->setup(
array(
'exceptionOnFailedSave' => true, //Throw an exception instead of returning false from saves
'notNullValidations' => false //Allow empty strings instead of the wtf new \Phalcon\Db\RawValue('""');
)
);
//Sets to only update the fields that are changed
$this->useDynamicUpdate(true);
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"this",
"->",
"keepSnapshots",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setup",
"(",
"array",
"(",
"'exceptionOnFailedSave'",
"=>",
"true",
",",
"//Throw an exception instead of returning false from saves",
... | Initializes the class
@return void | [
"Initializes",
"the",
"class"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L160-L170 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.addAutomaticallyUpdatedFields | public function addAutomaticallyUpdatedFields(array $automaticallyUpdatedFields) {
$fields = $this->getAutomaticallyUpdatedFields();
foreach($automaticallyUpdatedFields as $field) {
if(!in_array($field, $fields)) {
$fields[] = $field;
}
}
$this->setAutomaticallyUpdatedFields($fields);
} | php | public function addAutomaticallyUpdatedFields(array $automaticallyUpdatedFields) {
$fields = $this->getAutomaticallyUpdatedFields();
foreach($automaticallyUpdatedFields as $field) {
if(!in_array($field, $fields)) {
$fields[] = $field;
}
}
$this->setAutomaticallyUpdatedFields($fields);
} | [
"public",
"function",
"addAutomaticallyUpdatedFields",
"(",
"array",
"$",
"automaticallyUpdatedFields",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getAutomaticallyUpdatedFields",
"(",
")",
";",
"foreach",
"(",
"$",
"automaticallyUpdatedFields",
"as",
"$",
"fi... | Adds any new automatically updated fields, so they cannot be updated by the controller
@param array $automaticallyUpdatedFields
@return void | [
"Adds",
"any",
"new",
"automatically",
"updated",
"fields",
"so",
"they",
"cannot",
"be",
"updated",
"by",
"the",
"controller"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L195-L203 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.readAttribute | public function readAttribute($name) {
$method = 'get' . ucfirst($name);
if(method_exists($this, $method)) {
return $this->$method();
} else {
return parent::readAttribute($name);
}
} | php | public function readAttribute($name) {
$method = 'get' . ucfirst($name);
if(method_exists($this, $method)) {
return $this->$method();
} else {
return parent::readAttribute($name);
}
} | [
"public",
"function",
"readAttribute",
"(",
"$",
"name",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->"... | Override readAttribute to allow for having custom setMethods
@param string $name
@return mixed | [
"Override",
"readAttribute",
"to",
"allow",
"for",
"having",
"custom",
"setMethods"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L270-L277 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.writeAttribute | public function writeAttribute($name, $value) {
$method = 'set' . ucfirst($name);
if(method_exists($this, $method)) {
$this->$method($value);
} else {
parent::writeAttribute($name, $value);
}
} | php | public function writeAttribute($name, $value) {
$method = 'set' . ucfirst($name);
if(method_exists($this, $method)) {
$this->$method($value);
} else {
parent::writeAttribute($name, $value);
}
} | [
"public",
"function",
"writeAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
... | Override writeAttribute to allow for having custom setMethods
@param string $name
@param string $value
@return void | [
"Override",
"writeAttribute",
"to",
"allow",
"for",
"having",
"custom",
"setMethods"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L287-L294 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.convertColumnsToRawFields | private function convertColumnsToRawFields(array $columns) {
$columnMaps = $this->getModelsMetaData()->getColumnMap($this);
foreach($columns as $key => $value) {
if(!array_key_exists($value, $columnMaps)) {
//Look up in the changed values
$index = array_search($value, $columnMaps);
if($index === false) {
throw new \InvalidArgumentException('Invalid Column, could not find: ' . $value);
} else {
$columns[$key] = $index;
}
}
}
return $columns;
} | php | private function convertColumnsToRawFields(array $columns) {
$columnMaps = $this->getModelsMetaData()->getColumnMap($this);
foreach($columns as $key => $value) {
if(!array_key_exists($value, $columnMaps)) {
//Look up in the changed values
$index = array_search($value, $columnMaps);
if($index === false) {
throw new \InvalidArgumentException('Invalid Column, could not find: ' . $value);
} else {
$columns[$key] = $index;
}
}
}
return $columns;
} | [
"private",
"function",
"convertColumnsToRawFields",
"(",
"array",
"$",
"columns",
")",
"{",
"$",
"columnMaps",
"=",
"$",
"this",
"->",
"getModelsMetaData",
"(",
")",
"->",
"getColumnMap",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$... | Converts the columns into their original raw fields
@param string[] $columns
@return \string[] | [
"Converts",
"the",
"columns",
"into",
"their",
"original",
"raw",
"fields"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L367-L381 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.getRelationship | public function getRelationship($alias) {
if(array_key_exists($alias, $this->getCustomParentRelationships())) {
return $this->getCustomParentRelationships()[$alias];
} else {
return $this->getModelsManager()->getRelationByAlias(get_class($this), $alias);
}
} | php | public function getRelationship($alias) {
if(array_key_exists($alias, $this->getCustomParentRelationships())) {
return $this->getCustomParentRelationships()[$alias];
} else {
return $this->getModelsManager()->getRelationByAlias(get_class($this), $alias);
}
} | [
"public",
"function",
"getRelationship",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"getCustomParentRelationships",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getCustomParentRelationships"... | Finds a relationship
@param string $alias
@return Model\Relation|false | [
"Finds",
"a",
"relationship"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L390-L396 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.setRelated | public function setRelated($alias, Model $entity) {
$foundRelation = $this->getRelationship($alias);
if($foundRelation instanceof CustomRelationship) {
call_user_func(array($this, 'set' . ucfirst($alias)), $entity);
} else {
$attribute = $foundRelation->getFields();
$value = $foundRelation->getReferencedFields();
if(is_array($attribute)) {
$count = sizeOf($attribute);
for($i = 0; $i < $count; $i++) {
$this->writeAttribute($attribute[$i], $entity->readAttribute($value[$i]));
}
} else {
$this->writeAttribute($attribute, $entity->readAttribute($value));
}
}
} | php | public function setRelated($alias, Model $entity) {
$foundRelation = $this->getRelationship($alias);
if($foundRelation instanceof CustomRelationship) {
call_user_func(array($this, 'set' . ucfirst($alias)), $entity);
} else {
$attribute = $foundRelation->getFields();
$value = $foundRelation->getReferencedFields();
if(is_array($attribute)) {
$count = sizeOf($attribute);
for($i = 0; $i < $count; $i++) {
$this->writeAttribute($attribute[$i], $entity->readAttribute($value[$i]));
}
} else {
$this->writeAttribute($attribute, $entity->readAttribute($value));
}
}
} | [
"public",
"function",
"setRelated",
"(",
"$",
"alias",
",",
"Model",
"$",
"entity",
")",
"{",
"$",
"foundRelation",
"=",
"$",
"this",
"->",
"getRelationship",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"foundRelation",
"instanceof",
"CustomRelationship",
... | Sets a related entity
@param string $alias
@param Model $entity
@return void | [
"Sets",
"a",
"related",
"entity"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L406-L422 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.getRelated | public function getRelated($alias, $arguments = null) {
$relationship = $this->getRelationship($alias);
if(($relationship === false || $relationship instanceof CustomRelationship) && method_exists($this, "get" . ucfirst($alias))) {
return call_user_func(array($this, "get" . ucfirst($alias)));
}
return parent::getRelated($alias, $arguments);
} | php | public function getRelated($alias, $arguments = null) {
$relationship = $this->getRelationship($alias);
if(($relationship === false || $relationship instanceof CustomRelationship) && method_exists($this, "get" . ucfirst($alias))) {
return call_user_func(array($this, "get" . ucfirst($alias)));
}
return parent::getRelated($alias, $arguments);
} | [
"public",
"function",
"getRelated",
"(",
"$",
"alias",
",",
"$",
"arguments",
"=",
"null",
")",
"{",
"$",
"relationship",
"=",
"$",
"this",
"->",
"getRelationship",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"(",
"$",
"relationship",
"===",
"false",
"||",... | Gets related entities.
@param String $alias
@param null $arguments
@return ResultSet | [
"Gets",
"related",
"entities",
"."
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L432-L438 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.selectReadConnection | public function selectReadConnection() {
$transaction = new Transaction($this->getReadConnectionService());
if($transaction->isInTransaction()) {
return $transaction->getTransaction()->getConnection();
} else {
return $this->getReadConnection();
}
} | php | public function selectReadConnection() {
$transaction = new Transaction($this->getReadConnectionService());
if($transaction->isInTransaction()) {
return $transaction->getTransaction()->getConnection();
} else {
return $this->getReadConnection();
}
} | [
"public",
"function",
"selectReadConnection",
"(",
")",
"{",
"$",
"transaction",
"=",
"new",
"Transaction",
"(",
"$",
"this",
"->",
"getReadConnectionService",
"(",
")",
")",
";",
"if",
"(",
"$",
"transaction",
"->",
"isInTransaction",
"(",
")",
")",
"{",
... | Used to be able to make a call inside of a transaction
@return \Phalcon\Db\AdapterInterface | [
"Used",
"to",
"be",
"able",
"to",
"make",
"a",
"call",
"inside",
"of",
"a",
"transaction"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L444-L451 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Models/Base.php | Base.getAllBehaviorsByClassName | public function getAllBehaviorsByClassName($className) {
$modelsManager = $this->getModelsManager();
$reflectionClass = new \ReflectionClass($modelsManager);
$reflectionBehavior = $reflectionClass->getProperty('_behaviors');
$reflectionBehavior->setAccessible(true);
/** @var array $allBehaviors */
$allBehaviors = $reflectionBehavior->getValue($modelsManager);
/** @var Model\BehaviorInterface[] $behaviors */
$behaviors = $allBehaviors[strtolower(get_class($this))];
/** @var Model\BehaviorInterface[] $returnVar */
$returnVar = [];
foreach($behaviors as $behavior) {
if(get_class($behavior) == $className || is_subclass_of($behavior, $className)) {
$returnVar[] = $behavior;
}
}
return $returnVar;
} | php | public function getAllBehaviorsByClassName($className) {
$modelsManager = $this->getModelsManager();
$reflectionClass = new \ReflectionClass($modelsManager);
$reflectionBehavior = $reflectionClass->getProperty('_behaviors');
$reflectionBehavior->setAccessible(true);
/** @var array $allBehaviors */
$allBehaviors = $reflectionBehavior->getValue($modelsManager);
/** @var Model\BehaviorInterface[] $behaviors */
$behaviors = $allBehaviors[strtolower(get_class($this))];
/** @var Model\BehaviorInterface[] $returnVar */
$returnVar = [];
foreach($behaviors as $behavior) {
if(get_class($behavior) == $className || is_subclass_of($behavior, $className)) {
$returnVar[] = $behavior;
}
}
return $returnVar;
} | [
"public",
"function",
"getAllBehaviorsByClassName",
"(",
"$",
"className",
")",
"{",
"$",
"modelsManager",
"=",
"$",
"this",
"->",
"getModelsManager",
"(",
")",
";",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"modelsManager",
")",
"... | Returns all behaviors associated with the class
@param string $className
@return Model\BehaviorInterface[] | [
"Returns",
"all",
"behaviors",
"associated",
"with",
"the",
"class"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Models/Base.php#L502-L522 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.addConstant | public function addConstant($name, $value) {
$constants = $this->getConstants();
if(array_key_exists($name, $constants)) {
throw new \Exception('Constant Already Exists: ' . $name);
}
$constants[$name] = $value;
asort($constants);
$this->setConstants($constants);
} | php | public function addConstant($name, $value) {
$constants = $this->getConstants();
if(array_key_exists($name, $constants)) {
throw new \Exception('Constant Already Exists: ' . $name);
}
$constants[$name] = $value;
asort($constants);
$this->setConstants($constants);
} | [
"public",
"function",
"addConstant",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"constants",
"=",
"$",
"this",
"->",
"getConstants",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"constants",
")",
")",
"{",
"throw... | Adds a new class constant
@param string $name
@param string $value
@return void
@throws \Exception | [
"Adds",
"a",
"new",
"class",
"constant"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L129-L137 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.hasConstant | public function hasConstant($name) {
$hasConstant = false;
if(array_key_exists($name, $this->getConstants())) {
$hasConstant = true;
}
return $hasConstant;
} | php | public function hasConstant($name) {
$hasConstant = false;
if(array_key_exists($name, $this->getConstants())) {
$hasConstant = true;
}
return $hasConstant;
} | [
"public",
"function",
"hasConstant",
"(",
"$",
"name",
")",
"{",
"$",
"hasConstant",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getConstants",
"(",
")",
")",
")",
"{",
"$",
"hasConstant",
"=",
"true",
... | Checks if the constant exists
@param string $name The name of the constant you are looking for
@return bool | [
"Checks",
"if",
"the",
"constant",
"exists"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L146-L153 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.addUse | public function addUse($use) {
$use = trim($use, '\\');
$uses = $this->getUses();
if(!in_array($use, $uses)) {
$uses[] = $use;
}
sort($uses);
$this->setUses($uses);
} | php | public function addUse($use) {
$use = trim($use, '\\');
$uses = $this->getUses();
if(!in_array($use, $uses)) {
$uses[] = $use;
}
sort($uses);
$this->setUses($uses);
} | [
"public",
"function",
"addUse",
"(",
"$",
"use",
")",
"{",
"$",
"use",
"=",
"trim",
"(",
"$",
"use",
",",
"'\\\\'",
")",
";",
"$",
"uses",
"=",
"$",
"this",
"->",
"getUses",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"use",
",",
"$"... | Adds a new use
@param string $use
@return void | [
"Adds",
"a",
"new",
"use"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L309-L317 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.toString | public function toString() {
$documentation = preg_replace_callback(
'@\r?\n@',
function ($matches) {
return $matches[0] . ' * ';
},
trim($this->getDocumentation())
);
if($documentation == '') {
$documentation = $this->getName();
}
$buffer = '<?php
namespace ' . $this->getNamespace() . ';
';
foreach($this->getUses() as $use) {
$buffer .= 'use ' . $use . ';' . "\n";
}
$buffer .= '/**
* ' . $documentation . '
*/
' . ($this->isAbstract() ? 'abstract ' : '') . 'class ' . $this->getName() . ' extends ' . $this->getExtends() . (sizeOf($this->getImplements()) > 0 ? ' implements ' . implode(', ', $this->getImplements()) : '') . ' {
';
foreach($this->getTraits() as $trait) {
$buffer .= ' use ' . $trait . ';
';
}
foreach($this->getConstants() as $name => $value) {
$buffer .= ' const ' . $name . ' = \'' . str_replace("'", "\\'", $value) . '\';
';
}
foreach($this->getVariables() as $variable) {
$buffer .= $variable->toString();
}
foreach($this->getMethods() as $method) {
$buffer .= $method->toString();
}
$buffer .= '}';
return str_replace("\r\n", "\n", $buffer);
} | php | public function toString() {
$documentation = preg_replace_callback(
'@\r?\n@',
function ($matches) {
return $matches[0] . ' * ';
},
trim($this->getDocumentation())
);
if($documentation == '') {
$documentation = $this->getName();
}
$buffer = '<?php
namespace ' . $this->getNamespace() . ';
';
foreach($this->getUses() as $use) {
$buffer .= 'use ' . $use . ';' . "\n";
}
$buffer .= '/**
* ' . $documentation . '
*/
' . ($this->isAbstract() ? 'abstract ' : '') . 'class ' . $this->getName() . ' extends ' . $this->getExtends() . (sizeOf($this->getImplements()) > 0 ? ' implements ' . implode(', ', $this->getImplements()) : '') . ' {
';
foreach($this->getTraits() as $trait) {
$buffer .= ' use ' . $trait . ';
';
}
foreach($this->getConstants() as $name => $value) {
$buffer .= ' const ' . $name . ' = \'' . str_replace("'", "\\'", $value) . '\';
';
}
foreach($this->getVariables() as $variable) {
$buffer .= $variable->toString();
}
foreach($this->getMethods() as $method) {
$buffer .= $method->toString();
}
$buffer .= '}';
return str_replace("\r\n", "\n", $buffer);
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"documentation",
"=",
"preg_replace_callback",
"(",
"'@\\r?\\n@'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"0",
"]",
".",
"' * '",
";",
"}",
",",
"trim",
"(",
... | Converts this class to a string
@return string | [
"Converts",
"this",
"class",
"to",
"a",
"string"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L339-L377 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.getFileName | public function getFileName() {
$isTestClass = substr($this->getName(), -4) == 'Test';
if($isTestClass) {
$rootDirectory = $this->getConfiguration()->getRootTestDirectory();
} else {
$rootDirectory = $this->getConfiguration()->getRootDirectory();
}
if(substr($this->getNamespace(), 0, strlen($this->getConfiguration()->getRootNamespace())) != $this->getConfiguration()->getRootNamespace()) {
throw new \Exception('The Root namespace does not match this classes namespace, could not get the file name'."\n".$this->getNamespace()."\n".$this->getConfiguration()->getRootNamespace());
}
if($isTestClass) {
$namespace = $this->getNamespace();
} else {
$namespace = substr($this->getNamespace(), strlen($this->getConfiguration()->getRootNamespace()));
}
if(DIRECTORY_SEPARATOR != '\\') {
$namespace = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
}
return $rootDirectory . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . $this->getName() . '.php';
} | php | public function getFileName() {
$isTestClass = substr($this->getName(), -4) == 'Test';
if($isTestClass) {
$rootDirectory = $this->getConfiguration()->getRootTestDirectory();
} else {
$rootDirectory = $this->getConfiguration()->getRootDirectory();
}
if(substr($this->getNamespace(), 0, strlen($this->getConfiguration()->getRootNamespace())) != $this->getConfiguration()->getRootNamespace()) {
throw new \Exception('The Root namespace does not match this classes namespace, could not get the file name'."\n".$this->getNamespace()."\n".$this->getConfiguration()->getRootNamespace());
}
if($isTestClass) {
$namespace = $this->getNamespace();
} else {
$namespace = substr($this->getNamespace(), strlen($this->getConfiguration()->getRootNamespace()));
}
if(DIRECTORY_SEPARATOR != '\\') {
$namespace = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
}
return $rootDirectory . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . $this->getName() . '.php';
} | [
"public",
"function",
"getFileName",
"(",
")",
"{",
"$",
"isTestClass",
"=",
"substr",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"-",
"4",
")",
"==",
"'Test'",
";",
"if",
"(",
"$",
"isTestClass",
")",
"{",
"$",
"rootDirectory",
"=",
"$",
"t... | Gets the filename for this class
@return string
@throws \Exception | [
"Gets",
"the",
"filename",
"for",
"this",
"class"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L384-L403 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Object/Index.php | Index.write | public function write() {
$filename = $this->getFileName();
if(basename($filename) == '.php') {
throw new CatchableException('Invalid Filename: '.$filename);
}
if(!is_dir(dirname($filename))) {
mkdir(dirname($filename), 0777, true);
}
file_put_contents($filename, $this->toString());
} | php | public function write() {
$filename = $this->getFileName();
if(basename($filename) == '.php') {
throw new CatchableException('Invalid Filename: '.$filename);
}
if(!is_dir(dirname($filename))) {
mkdir(dirname($filename), 0777, true);
}
file_put_contents($filename, $this->toString());
} | [
"public",
"function",
"write",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"basename",
"(",
"$",
"filename",
")",
"==",
"'.php'",
")",
"{",
"throw",
"new",
"CatchableException",
"(",
"'Invalid Filename... | Writes this class to the server
@return void | [
"Writes",
"this",
"class",
"to",
"the",
"server"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Object/Index.php#L409-L418 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Date.php | Date.getOffsetDay | public function getOffsetDay($offsetNumDays) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()),
date('j', $this->getEpoch()) + $offsetNumDays,
date('Y', $this->getEpoch())
)
);
} | php | public function getOffsetDay($offsetNumDays) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()),
date('j', $this->getEpoch()) + $offsetNumDays,
date('Y', $this->getEpoch())
)
);
} | [
"public",
"function",
"getOffsetDay",
"(",
"$",
"offsetNumDays",
")",
"{",
"return",
"new",
"self",
"(",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"date",
"(",
"'n'",
",",
"$",
"this",
"->",
"getEpoch",
"(",
")",
")",
",",
"date",
"(",
"'j'",
... | Gets an offset day
@param int $offsetNumDays
@return Date | [
"Gets",
"an",
"offset",
"day"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Date.php#L171-L182 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Date.php | Date.getOffsetYear | public function getOffsetYear($offsetNumYears) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()),
date('j', $this->getEpoch()),
date('Y', $this->getEpoch()) + $offsetNumYears
)
);
} | php | public function getOffsetYear($offsetNumYears) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()),
date('j', $this->getEpoch()),
date('Y', $this->getEpoch()) + $offsetNumYears
)
);
} | [
"public",
"function",
"getOffsetYear",
"(",
"$",
"offsetNumYears",
")",
"{",
"return",
"new",
"self",
"(",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"date",
"(",
"'n'",
",",
"$",
"this",
"->",
"getEpoch",
"(",
")",
")",
",",
"date",
"(",
"'j'",
... | Gets an offset of years
@param int $offsetNumYears
@return Date | [
"Gets",
"an",
"offset",
"of",
"years"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Date.php#L207-L218 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Date.php | Date.getOffsetMonth | public function getOffsetMonth($offsetNumMonths) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()) + $offsetNumMonths,
date('j', $this->getEpoch()),
date('Y', $this->getEpoch())
)
);
} | php | public function getOffsetMonth($offsetNumMonths) {
return new self(
mktime(
0,
0,
0,
date('n', $this->getEpoch()) + $offsetNumMonths,
date('j', $this->getEpoch()),
date('Y', $this->getEpoch())
)
);
} | [
"public",
"function",
"getOffsetMonth",
"(",
"$",
"offsetNumMonths",
")",
"{",
"return",
"new",
"self",
"(",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"date",
"(",
"'n'",
",",
"$",
"this",
"->",
"getEpoch",
"(",
")",
")",
"+",
"$",
"offsetNumMonth... | Gets an offset of months
@param int $offsetNumMonths
@return Date | [
"Gets",
"an",
"offset",
"of",
"months"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Date.php#L227-L238 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Date/Date.php | Date.getStartOfWeek | public function getStartOfWeek($offset = null) {
$dayInWeek = $this->getEpoch();
if(date('G', $dayInWeek) < 6) {
$dayInWeek += 60 * 60 * 12; //Offset for daylight savings time
}
$week = date('w', $dayInWeek);
if(is_null($offset)) {
$offset = $this->getFormatter()->getWeekOffset();
}
if($week >= $offset) {
$day = date('j', $dayInWeek) - date('w', $dayInWeek) + $offset;
} else { //Go To previous week
$day = date('j', $dayInWeek) - date('w', $dayInWeek) + $offset - 7;
}
return new self(mktime(12, 0, 0, date('n', $dayInWeek), $day, date('Y', $dayInWeek)));
} | php | public function getStartOfWeek($offset = null) {
$dayInWeek = $this->getEpoch();
if(date('G', $dayInWeek) < 6) {
$dayInWeek += 60 * 60 * 12; //Offset for daylight savings time
}
$week = date('w', $dayInWeek);
if(is_null($offset)) {
$offset = $this->getFormatter()->getWeekOffset();
}
if($week >= $offset) {
$day = date('j', $dayInWeek) - date('w', $dayInWeek) + $offset;
} else { //Go To previous week
$day = date('j', $dayInWeek) - date('w', $dayInWeek) + $offset - 7;
}
return new self(mktime(12, 0, 0, date('n', $dayInWeek), $day, date('Y', $dayInWeek)));
} | [
"public",
"function",
"getStartOfWeek",
"(",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"dayInWeek",
"=",
"$",
"this",
"->",
"getEpoch",
"(",
")",
";",
"if",
"(",
"date",
"(",
"'G'",
",",
"$",
"dayInWeek",
")",
"<",
"6",
")",
"{",
"$",
"dayInWeek",... | Gets the first second in a week
@param int|null $offset
@return Date | [
"Gets",
"the",
"first",
"second",
"in",
"a",
"week"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Date/Date.php#L279-L294 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Generator/Swagger/Api.php | Api.addOperation | public function addOperation(Operation $operation) {
$operations = $this->getOperations();
$operations[] = $operation;
$this->setOperations($operations);
} | php | public function addOperation(Operation $operation) {
$operations = $this->getOperations();
$operations[] = $operation;
$this->setOperations($operations);
} | [
"public",
"function",
"addOperation",
"(",
"Operation",
"$",
"operation",
")",
"{",
"$",
"operations",
"=",
"$",
"this",
"->",
"getOperations",
"(",
")",
";",
"$",
"operations",
"[",
"]",
"=",
"$",
"operation",
";",
"$",
"this",
"->",
"setOperations",
"(... | Adds new operation
@param Operation $operation
@return void | [
"Adds",
"new",
"operation"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Generator/Swagger/Api.php#L50-L54 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/DbCompare/Line.php | Line.equals | public function equals(Line $line, $prefix) {
$prefix .= ': Column (' . $this->getName() . '):';
$errors = [];
if($line->getName() !== $this->getName()) {
throw new \Exception('Comparing Incomparable columns');
}
if($line->getType() !== $this->getType()) {
$errors[] = $prefix . 'Type Does Not Match:' . "\n" . $line->getType() . "\n" . $this->getType();
}
if($line->isUnsigned() !== $this->isUnsigned()) {
$errors[] = $prefix . 'Unsigned Does Not Match:' . "\n" . $line->isUnsigned() . "\n" . $this->isUnsigned();
}
if($line->isNullable() !== $this->isNullable()) {
$errors[] = $prefix . 'Nullable Does Not Match:' . "\n" . $line->isNullable() . "\n" . $this->isNullable();
}
if($line->isAutoIncrement() !== $this->isAutoIncrement()) {
$errors[] = $prefix . 'AutoIncrement Does Not Match:' . "\n" . $line->isAutoIncrement() . "\n" . $this->isAutoIncrement();
}
if($line->getCollate() !== $this->getCollate()) {
$errors[] = $prefix . 'Collate Does Not Match:' . "\n" . $line->getCollate() . "\n" . $this->getCollate();
}
if($line->getComment() !== $this->getComment()) {
$errors[] = $prefix . 'Comment Does Not Match:' . "\n" . $line->getComment() . "\n" . $this->getComment();
}
if($line->getDefault() !== $this->getDefault()) {
$errors[] = $prefix . 'Default Does Not Match:' . "\n" . $line->getDefault() . "\n" . $this->getDefault();
}
return $errors;
} | php | public function equals(Line $line, $prefix) {
$prefix .= ': Column (' . $this->getName() . '):';
$errors = [];
if($line->getName() !== $this->getName()) {
throw new \Exception('Comparing Incomparable columns');
}
if($line->getType() !== $this->getType()) {
$errors[] = $prefix . 'Type Does Not Match:' . "\n" . $line->getType() . "\n" . $this->getType();
}
if($line->isUnsigned() !== $this->isUnsigned()) {
$errors[] = $prefix . 'Unsigned Does Not Match:' . "\n" . $line->isUnsigned() . "\n" . $this->isUnsigned();
}
if($line->isNullable() !== $this->isNullable()) {
$errors[] = $prefix . 'Nullable Does Not Match:' . "\n" . $line->isNullable() . "\n" . $this->isNullable();
}
if($line->isAutoIncrement() !== $this->isAutoIncrement()) {
$errors[] = $prefix . 'AutoIncrement Does Not Match:' . "\n" . $line->isAutoIncrement() . "\n" . $this->isAutoIncrement();
}
if($line->getCollate() !== $this->getCollate()) {
$errors[] = $prefix . 'Collate Does Not Match:' . "\n" . $line->getCollate() . "\n" . $this->getCollate();
}
if($line->getComment() !== $this->getComment()) {
$errors[] = $prefix . 'Comment Does Not Match:' . "\n" . $line->getComment() . "\n" . $this->getComment();
}
if($line->getDefault() !== $this->getDefault()) {
$errors[] = $prefix . 'Default Does Not Match:' . "\n" . $line->getDefault() . "\n" . $this->getDefault();
}
return $errors;
} | [
"public",
"function",
"equals",
"(",
"Line",
"$",
"line",
",",
"$",
"prefix",
")",
"{",
"$",
"prefix",
".=",
"': Column ('",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'):'",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"line",... | Compares two lines, and returns any errors of non matches
@param Line $line
@param string $prefix
@return string[]
@throws \Exception | [
"Compares",
"two",
"lines",
"and",
"returns",
"any",
"errors",
"of",
"non",
"matches"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/DbCompare/Line.php#L41-L69 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/Base.php | Base.addFile | protected function addFile(File $file) {
$files = $this->getFiles();
$files[$file->getName()] = $file;
$this->setFiles($files);
} | php | protected function addFile(File $file) {
$files = $this->getFiles();
$files[$file->getName()] = $file;
$this->setFiles($files);
} | [
"protected",
"function",
"addFile",
"(",
"File",
"$",
"file",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getFiles",
"(",
")",
";",
"$",
"files",
"[",
"$",
"file",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"file",
";",
"$",
"this",
"->",
"... | Add a new file
@param File $file
@return void | [
"Add",
"a",
"new",
"file"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/Base.php#L47-L51 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/Base.php | Base.validateAllRequired | private function validateAllRequired($isCreating) {
foreach($this->getFiles() as $file) {
if(!$file->isUsed()) {
if($isCreating ? $file->isRequiredOnCreate() : $file->isRequiredOnUpdate()) {
$this->getEntity()->appendMessage(new Message('Missing the required file of: ' . $file->getName()));
}
}
}
if($this->getEntity()->validationHasFailed() == true) {
$validationException = new ValidationException();
$validationException->setEntity($this->getEntity());
throw $validationException;
}
} | php | private function validateAllRequired($isCreating) {
foreach($this->getFiles() as $file) {
if(!$file->isUsed()) {
if($isCreating ? $file->isRequiredOnCreate() : $file->isRequiredOnUpdate()) {
$this->getEntity()->appendMessage(new Message('Missing the required file of: ' . $file->getName()));
}
}
}
if($this->getEntity()->validationHasFailed() == true) {
$validationException = new ValidationException();
$validationException->setEntity($this->getEntity());
throw $validationException;
}
} | [
"private",
"function",
"validateAllRequired",
"(",
"$",
"isCreating",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFiles",
"(",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"file",
"->",
"isUsed",
"(",
")",
")",
"{",
"if",
"(",
"$",
... | Validates that all required files were passed in
@param bool $isCreating
@return void
@throws ValidationException | [
"Validates",
"that",
"all",
"required",
"files",
"were",
"passed",
"in"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/Behavior/Upload/Base.php#L127-L140 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php | Save.lookUpAutomaticFields | private function lookUpAutomaticFields(ApiInterface $entity, $isCreating) {
if($isCreating) {
$automaticAttributes = $entity->getModelsMetaData()->getAutomaticCreateAttributes($entity);
} else {
$automaticAttributes = $entity->getModelsMetaData()->getAutomaticUpdateAttributes($entity);
}
$columnMap = $entity->getModelsMetaData()->getColumnMap($entity);
$automaticFields = array_fill_keys($entity->getAutomaticallyUpdatedFields(), null);
foreach($automaticAttributes as $fullName => $null) {
$automaticFields[$columnMap[$fullName]] = null;
}
return $automaticFields;
} | php | private function lookUpAutomaticFields(ApiInterface $entity, $isCreating) {
if($isCreating) {
$automaticAttributes = $entity->getModelsMetaData()->getAutomaticCreateAttributes($entity);
} else {
$automaticAttributes = $entity->getModelsMetaData()->getAutomaticUpdateAttributes($entity);
}
$columnMap = $entity->getModelsMetaData()->getColumnMap($entity);
$automaticFields = array_fill_keys($entity->getAutomaticallyUpdatedFields(), null);
foreach($automaticAttributes as $fullName => $null) {
$automaticFields[$columnMap[$fullName]] = null;
}
return $automaticFields;
} | [
"private",
"function",
"lookUpAutomaticFields",
"(",
"ApiInterface",
"$",
"entity",
",",
"$",
"isCreating",
")",
"{",
"if",
"(",
"$",
"isCreating",
")",
"{",
"$",
"automaticAttributes",
"=",
"$",
"entity",
"->",
"getModelsMetaData",
"(",
")",
"->",
"getAutomat... | Looks up which fields are automatically updated
@param ApiInterface $entity
@param bool $isCreating
@return array | [
"Looks",
"up",
"which",
"fields",
"are",
"automatically",
"updated"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php#L122-L134 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php | Save.filterFields | private function filterFields(\stdClass $params, ApiInterface $entity, $isCreating) {
$automaticFields = $this->lookUpAutomaticFields($entity, $isCreating);
$customParentRelationshipFields = [];
foreach($entity->getCustomParentRelationships() as $customParentRelationshipField) {
$customParentRelationshipFields[] = $customParentRelationshipField->getFields();
}
$fields = array();
foreach($params as $key => $value) {
if(!(is_object($value) && get_class($value) == 'stdClass')) {
if(array_key_exists($key, $entity->getChildrenUpdaters())) {
$fields[$key] = $value;
} elseif(in_array($key, $entity->getModelsMetaData()->getColumnMap($entity)) || in_array($key, $customParentRelationshipFields)) {
if(array_key_exists($key, $automaticFields) && $entity->readAttribute($key) != $value) {
throw new Exception('The field of: ' . $key . ' cannot be manually updated', 409);
}
$fields[$key] = $value;
} else {
throw new Exception('Could not find the field: ' . $key, 400);
}
}
}
return $fields;
} | php | private function filterFields(\stdClass $params, ApiInterface $entity, $isCreating) {
$automaticFields = $this->lookUpAutomaticFields($entity, $isCreating);
$customParentRelationshipFields = [];
foreach($entity->getCustomParentRelationships() as $customParentRelationshipField) {
$customParentRelationshipFields[] = $customParentRelationshipField->getFields();
}
$fields = array();
foreach($params as $key => $value) {
if(!(is_object($value) && get_class($value) == 'stdClass')) {
if(array_key_exists($key, $entity->getChildrenUpdaters())) {
$fields[$key] = $value;
} elseif(in_array($key, $entity->getModelsMetaData()->getColumnMap($entity)) || in_array($key, $customParentRelationshipFields)) {
if(array_key_exists($key, $automaticFields) && $entity->readAttribute($key) != $value) {
throw new Exception('The field of: ' . $key . ' cannot be manually updated', 409);
}
$fields[$key] = $value;
} else {
throw new Exception('Could not find the field: ' . $key, 400);
}
}
}
return $fields;
} | [
"private",
"function",
"filterFields",
"(",
"\\",
"stdClass",
"$",
"params",
",",
"ApiInterface",
"$",
"entity",
",",
"$",
"isCreating",
")",
"{",
"$",
"automaticFields",
"=",
"$",
"this",
"->",
"lookUpAutomaticFields",
"(",
"$",
"entity",
",",
"$",
"isCreat... | Filters the params down to just the instance fields
@param \stdClass $params
@param ApiInterface $entity
@param bool $isCreating
@return string[]
@throws Exception | [
"Filters",
"the",
"params",
"down",
"to",
"just",
"the",
"instance",
"fields"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php#L146-L168 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php | Save.filterParents | private function filterParents(\stdClass $params, ApiInterface $entity) {
$parents = array();
foreach($params as $key => $value) {
if(is_object($value) && get_class($value) == 'stdClass') {
$alias = ucfirst($key);
if(in_array($alias, $entity->getParentRelationships())) {
$parents[$alias] = $value;
} else {
throw new Exception('Could not find the parent field: ' . $key, 400);
}
}
}
return $parents;
} | php | private function filterParents(\stdClass $params, ApiInterface $entity) {
$parents = array();
foreach($params as $key => $value) {
if(is_object($value) && get_class($value) == 'stdClass') {
$alias = ucfirst($key);
if(in_array($alias, $entity->getParentRelationships())) {
$parents[$alias] = $value;
} else {
throw new Exception('Could not find the parent field: ' . $key, 400);
}
}
}
return $parents;
} | [
"private",
"function",
"filterParents",
"(",
"\\",
"stdClass",
"$",
"params",
",",
"ApiInterface",
"$",
"entity",
")",
"{",
"$",
"parents",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"i... | Filters the params down to just the instance parents
@param \stdClass $params
@param ApiInterface $entity
@return \stdClass[]
@throws Exception | [
"Filters",
"the",
"params",
"down",
"to",
"just",
"the",
"instance",
"parents"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php#L179-L192 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php | Save.writeFields | private function writeFields($fields, ApiInterface $entity, bool $writeChildren): bool {
$isChanged = false;
foreach($fields as $name => $value) {
if($this->getAcl()->canWriteField($entity, $name)) {
try {
if(array_key_exists($name, $entity->getChildrenUpdaters())) {
if($writeChildren) {
$entity->getChildrenUpdaters()[$name]->setData($entity, $value);
$isChanged = true;
}
} else {
$entity->writeAttribute($name, $value);
}
} catch(\InvalidArgumentException $e) {
throw new CatchableException($e->getMessage());
}
}
}
return $isChanged;
} | php | private function writeFields($fields, ApiInterface $entity, bool $writeChildren): bool {
$isChanged = false;
foreach($fields as $name => $value) {
if($this->getAcl()->canWriteField($entity, $name)) {
try {
if(array_key_exists($name, $entity->getChildrenUpdaters())) {
if($writeChildren) {
$entity->getChildrenUpdaters()[$name]->setData($entity, $value);
$isChanged = true;
}
} else {
$entity->writeAttribute($name, $value);
}
} catch(\InvalidArgumentException $e) {
throw new CatchableException($e->getMessage());
}
}
}
return $isChanged;
} | [
"private",
"function",
"writeFields",
"(",
"$",
"fields",
",",
"ApiInterface",
"$",
"entity",
",",
"bool",
"$",
"writeChildren",
")",
":",
"bool",
"{",
"$",
"isChanged",
"=",
"false",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"v... | Writes the actual fields
@param string[] $fields
@param ApiInterface $entity
@return bool | [
"Writes",
"the",
"actual",
"fields"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php#L202-L221 | train |
bullhorn/fast-rest | Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php | Save.writeCustomParents | private function writeCustomParents($fields, ApiInterface $entity) {
foreach($entity->getCustomParentRelationships() as $customRelationship) {
$name = $customRelationship->getReferencedFields();
if(array_key_exists($name, $fields)) {
$entity->writeAttribute($name, $fields[$name]);
}
}
} | php | private function writeCustomParents($fields, ApiInterface $entity) {
foreach($entity->getCustomParentRelationships() as $customRelationship) {
$name = $customRelationship->getReferencedFields();
if(array_key_exists($name, $fields)) {
$entity->writeAttribute($name, $fields[$name]);
}
}
} | [
"private",
"function",
"writeCustomParents",
"(",
"$",
"fields",
",",
"ApiInterface",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"entity",
"->",
"getCustomParentRelationships",
"(",
")",
"as",
"$",
"customRelationship",
")",
"{",
"$",
"name",
"=",
"$",
"c... | Writes the custom parent fields
@param string[] $fields
@param ApiInterface $entity
@return void | [
"Writes",
"the",
"custom",
"parent",
"fields"
] | ac808abf6245144a1a885a3192a8f84debdf3118 | https://github.com/bullhorn/fast-rest/blob/ac808abf6245144a1a885a3192a8f84debdf3118/Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Save.php#L231-L238 | train |
dereuromark/cakephp-tools | src/View/Helper/GravatarHelper.php | GravatarHelper.image | public function image($email, array $options = []) {
$imageUrl = $this->url($email, $options);
unset($options['default'], $options['size'], $options['rating'], $options['ext']);
return $this->Html->image($imageUrl, $options);
} | php | public function image($email, array $options = []) {
$imageUrl = $this->url($email, $options);
unset($options['default'], $options['size'], $options['rating'], $options['ext']);
return $this->Html->image($imageUrl, $options);
} | [
"public",
"function",
"image",
"(",
"$",
"email",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"imageUrl",
"=",
"$",
"this",
"->",
"url",
"(",
"$",
"email",
",",
"$",
"options",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'defaul... | Show gravatar for the supplied email address
@param string $email Email address
@param array $options Array of options, keyed from default settings
@return string Gravatar image string | [
"Show",
"gravatar",
"for",
"the",
"supplied",
"email",
"address"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/View/Helper/GravatarHelper.php#L83-L87 | train |
dereuromark/cakephp-tools | src/View/Helper/GravatarHelper.php | GravatarHelper.defaultImages | public function defaultImages($options = []) {
$options = $this->_cleanOptions($options + $this->_config);
$images = [];
foreach ($this->_defaultIcons as $defaultIcon) {
$options['default'] = $defaultIcon;
$images[$defaultIcon] = $this->image(null, $options);
}
return $images;
} | php | public function defaultImages($options = []) {
$options = $this->_cleanOptions($options + $this->_config);
$images = [];
foreach ($this->_defaultIcons as $defaultIcon) {
$options['default'] = $defaultIcon;
$images[$defaultIcon] = $this->image(null, $options);
}
return $images;
} | [
"public",
"function",
"defaultImages",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"_cleanOptions",
"(",
"$",
"options",
"+",
"$",
"this",
"->",
"_config",
")",
";",
"$",
"images",
"=",
"[",
"]",
";",
"fore... | Generate an array of default images for preview purposes
@param array $options Array of options, keyed from default settings
@return array Default images array | [
"Generate",
"an",
"array",
"of",
"default",
"images",
"for",
"preview",
"purposes"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/View/Helper/GravatarHelper.php#L120-L128 | train |
dereuromark/cakephp-tools | src/View/Helper/GravatarHelper.php | GravatarHelper._cleanOptions | protected function _cleanOptions($options) {
if (!isset($options['size']) || empty($options['size']) || !is_numeric($options['size'])) {
unset($options['size']);
} else {
$options['size'] = min(max($options['size'], 1), 512);
}
if (!$options['rating'] || !in_array(mb_strtolower($options['rating']), $this->_allowedRatings)) {
unset($options['rating']);
}
if (!$options['default']) {
unset($options['default']);
} else {
if (!in_array($options['default'], $this->_defaultIcons) && !Validation::url($options['default'])) {
unset($options['default']);
}
}
return $options;
} | php | protected function _cleanOptions($options) {
if (!isset($options['size']) || empty($options['size']) || !is_numeric($options['size'])) {
unset($options['size']);
} else {
$options['size'] = min(max($options['size'], 1), 512);
}
if (!$options['rating'] || !in_array(mb_strtolower($options['rating']), $this->_allowedRatings)) {
unset($options['rating']);
}
if (!$options['default']) {
unset($options['default']);
} else {
if (!in_array($options['default'], $this->_defaultIcons) && !Validation::url($options['default'])) {
unset($options['default']);
}
}
return $options;
} | [
"protected",
"function",
"_cleanOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
"||",
"empty",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"options",... | Sanitize the options array
@param array $options Array of options, keyed from default settings
@return array Clean options array | [
"Sanitize",
"the",
"options",
"array"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/View/Helper/GravatarHelper.php#L136-L155 | train |
dereuromark/cakephp-tools | src/View/Helper/GravatarHelper.php | GravatarHelper._buildOptions | protected function _buildOptions($options = []) {
$gravatarOptions = array_intersect(array_keys($options), array_keys($this->_defaultConfig));
if (!empty($gravatarOptions)) {
$optionArray = [];
foreach ($gravatarOptions as $key) {
$value = $options[$key];
$optionArray[] = $key . '=' . mb_strtolower($value);
}
return '?' . implode('&', $optionArray);
}
return '';
} | php | protected function _buildOptions($options = []) {
$gravatarOptions = array_intersect(array_keys($options), array_keys($this->_defaultConfig));
if (!empty($gravatarOptions)) {
$optionArray = [];
foreach ($gravatarOptions as $key) {
$value = $options[$key];
$optionArray[] = $key . '=' . mb_strtolower($value);
}
return '?' . implode('&', $optionArray);
}
return '';
} | [
"protected",
"function",
"_buildOptions",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"gravatarOptions",
"=",
"array_intersect",
"(",
"array_keys",
"(",
"$",
"options",
")",
",",
"array_keys",
"(",
"$",
"this",
"->",
"_defaultConfig",
")",
")",
";",... | Build Options URL string
@param array $options Array of options, keyed from default settings
@return string URL string of options | [
"Build",
"Options",
"URL",
"string"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/View/Helper/GravatarHelper.php#L174-L185 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email._wrap | protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
if ($this->_wrapLength !== null) {
$wrapLength = $this->_wrapLength;
}
return parent::_wrap($message, $wrapLength);
} | php | protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
if ($this->_wrapLength !== null) {
$wrapLength = $this->_wrapLength;
}
return parent::_wrap($message, $wrapLength);
} | [
"protected",
"function",
"_wrap",
"(",
"$",
"message",
",",
"$",
"wrapLength",
"=",
"CakeEmail",
"::",
"LINE_LENGTH_MUST",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_wrapLength",
"!==",
"null",
")",
"{",
"$",
"wrapLength",
"=",
"$",
"this",
"->",
"_wrapLe... | Fix line length
@override To wrap by must length by default.
@param string $message Message to wrap
@param int $wrapLength
@return array Wrapped message | [
"Fix",
"line",
"length"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L114-L119 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email.setProfile | public function setProfile($config) {
if (!is_array($config)) {
$config = (string)$config;
}
$this->_applyConfig($config);
$fromEmail = Configure::read('Config.systemEmail');
if ($fromEmail) {
$fromName = Configure::read('Config.systemName');
} else {
$fromEmail = Configure::read('Config.adminEmail');
$fromName = Configure::read('Config.adminName');
}
if ($fromEmail) {
$this->setFrom($fromEmail, $fromName);
}
$xMailer = Configure::read('Config.xMailer');
if ($xMailer) {
$this->addHeaders(['X-Mailer' => $xMailer]);
}
return $this;
} | php | public function setProfile($config) {
if (!is_array($config)) {
$config = (string)$config;
}
$this->_applyConfig($config);
$fromEmail = Configure::read('Config.systemEmail');
if ($fromEmail) {
$fromName = Configure::read('Config.systemName');
} else {
$fromEmail = Configure::read('Config.adminEmail');
$fromName = Configure::read('Config.adminName');
}
if ($fromEmail) {
$this->setFrom($fromEmail, $fromName);
}
$xMailer = Configure::read('Config.xMailer');
if ($xMailer) {
$this->addHeaders(['X-Mailer' => $xMailer]);
}
return $this;
} | [
"public",
"function",
"setProfile",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"(",
"string",
")",
"$",
"config",
";",
"}",
"$",
"this",
"->",
"_applyConfig",
"(",
"$",
"config",... | Ovewrite to allow custom enhancements
@param array|string $config
@return $this | [
"Ovewrite",
"to",
"allow",
"custom",
"enhancements"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L141-L164 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email.setAttachments | public function setAttachments($attachments) {
$attach = [];
foreach ((array)$attachments as $name => $fileInfo) {
if (!is_array($fileInfo)) {
$fileInfo = ['file' => $fileInfo];
}
if (!isset($fileInfo['file'])) {
if (!isset($fileInfo['data'])) {
throw new InvalidArgumentException('No file or data specified.');
}
if (is_int($name)) {
throw new InvalidArgumentException('No filename specified.');
}
} else {
$fileName = $fileInfo['file'];
if (!preg_match('~^https?://~i', $fileInfo['file'])) {
$fileInfo['file'] = realpath($fileInfo['file']);
}
if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
}
if (is_int($name)) {
$name = basename($fileInfo['file']);
}
}
if (!isset($fileInfo['mimetype'])) {
$ext = pathinfo($name, PATHINFO_EXTENSION);
$fileInfo['mimetype'] = $this->_getMimeByExtension($ext);
}
$attach[$name] = $fileInfo;
}
$this->_attachments = $attach;
return $this;
} | php | public function setAttachments($attachments) {
$attach = [];
foreach ((array)$attachments as $name => $fileInfo) {
if (!is_array($fileInfo)) {
$fileInfo = ['file' => $fileInfo];
}
if (!isset($fileInfo['file'])) {
if (!isset($fileInfo['data'])) {
throw new InvalidArgumentException('No file or data specified.');
}
if (is_int($name)) {
throw new InvalidArgumentException('No filename specified.');
}
} else {
$fileName = $fileInfo['file'];
if (!preg_match('~^https?://~i', $fileInfo['file'])) {
$fileInfo['file'] = realpath($fileInfo['file']);
}
if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
}
if (is_int($name)) {
$name = basename($fileInfo['file']);
}
}
if (!isset($fileInfo['mimetype'])) {
$ext = pathinfo($name, PATHINFO_EXTENSION);
$fileInfo['mimetype'] = $this->_getMimeByExtension($ext);
}
$attach[$name] = $fileInfo;
}
$this->_attachments = $attach;
return $this;
} | [
"public",
"function",
"setAttachments",
"(",
"$",
"attachments",
")",
"{",
"$",
"attach",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"attachments",
"as",
"$",
"name",
"=>",
"$",
"fileInfo",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
... | Overwrite to allow mimetype detection
@param string|array $attachments String with the filename or array with filenames
@return $this
@throws \InvalidArgumentException | [
"Overwrite",
"to",
"allow",
"mimetype",
"detection"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L187-L221 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email.addAttachment | public function addAttachment($file, $name = null, $fileInfo = []) {
$fileInfo['file'] = $file;
if (!empty($name)) {
$fileInfo = [$name => $fileInfo];
} else {
$fileInfo = [$fileInfo];
}
return $this->addAttachments($fileInfo);
} | php | public function addAttachment($file, $name = null, $fileInfo = []) {
$fileInfo['file'] = $file;
if (!empty($name)) {
$fileInfo = [$name => $fileInfo];
} else {
$fileInfo = [$fileInfo];
}
return $this->addAttachments($fileInfo);
} | [
"public",
"function",
"addAttachment",
"(",
"$",
"file",
",",
"$",
"name",
"=",
"null",
",",
"$",
"fileInfo",
"=",
"[",
"]",
")",
"{",
"$",
"fileInfo",
"[",
"'file'",
"]",
"=",
"$",
"file",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
"... | Add an attachment from file
@param string $file Absolute path
@param string|null $name
@param array $fileInfo
@return $this | [
"Add",
"an",
"attachment",
"from",
"file"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L245-L253 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email.addBlobAttachment | public function addBlobAttachment($content, $filename, $mimeType = null, $fileInfo = []) {
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$fileInfo['data'] = $content;
$fileInfo['mimetype'] = $mimeType;
$file = [$filename => $fileInfo];
return $this->addAttachments($file);
} | php | public function addBlobAttachment($content, $filename, $mimeType = null, $fileInfo = []) {
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$fileInfo['data'] = $content;
$fileInfo['mimetype'] = $mimeType;
$file = [$filename => $fileInfo];
return $this->addAttachments($file);
} | [
"public",
"function",
"addBlobAttachment",
"(",
"$",
"content",
",",
"$",
"filename",
",",
"$",
"mimeType",
"=",
"null",
",",
"$",
"fileInfo",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"mimeType",
"===",
"null",
")",
"{",
"$",
"ext",
"=",
"pathinfo",
... | Add an attachment as blob
@param string $content Blob data
@param string $filename to attach it
@param string|null $mimeType (leave it empty to get mimetype from $filename)
@param array $fileInfo
@return $this | [
"Add",
"an",
"attachment",
"as",
"blob"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L264-L273 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email.addEmbeddedBlobAttachment | public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $options = null, array $notUsed = []) {
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$contentId = null;
// Deprecated $contentId here
if (!is_array($options)) {
$contentId = $options;
$options = $notUsed;
}
$filename = pathinfo($filename, PATHINFO_FILENAME) . '_' . md5($content) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
if ($contentId === null && ($cid = $this->_isEmbeddedBlobAttachment($content, $filename))) {
return $cid;
}
$options['data'] = $content;
$options['mimetype'] = $mimeType;
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
$file = [$filename => $options];
$this->addAttachments($file);
if ($contentId === null) {
return $options['contentId'];
}
// Deprecated
return $contentId;
} | php | public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $options = null, array $notUsed = []) {
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$contentId = null;
// Deprecated $contentId here
if (!is_array($options)) {
$contentId = $options;
$options = $notUsed;
}
$filename = pathinfo($filename, PATHINFO_FILENAME) . '_' . md5($content) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
if ($contentId === null && ($cid = $this->_isEmbeddedBlobAttachment($content, $filename))) {
return $cid;
}
$options['data'] = $content;
$options['mimetype'] = $mimeType;
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
$file = [$filename => $options];
$this->addAttachments($file);
if ($contentId === null) {
return $options['contentId'];
}
// Deprecated
return $contentId;
} | [
"public",
"function",
"addEmbeddedBlobAttachment",
"(",
"$",
"content",
",",
"$",
"filename",
",",
"$",
"mimeType",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"array",
"$",
"notUsed",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"mimeType",
"===",... | Add an inline attachment as blob
Options:
- contentDisposition
@param string $content Blob data
@param string $filename to attach it
@param string|null $mimeType (leave it empty to get mimetype from $filename)
@param array|string|null $options Options - string CID is deprecated
@param array $notUsed
@return string|null CID CcontentId (null is deprecated) | [
"Add",
"an",
"inline",
"attachment",
"as",
"blob"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L392-L421 | train |
dereuromark/cakephp-tools | src/Mailer/Email.php | Email._getMime | protected function _getMime($filename, $default = 'application/octet-stream') {
if (!isset($this->_Mime)) {
$this->_Mime = new Mime();
}
$mime = $this->_Mime->detectMimeType($filename);
// Some environments falsely return the default too fast, better fallback to extension here
if (!$mime || $mime === $default) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mime = $this->_Mime->getMimeTypeByAlias($ext);
}
return $mime;
} | php | protected function _getMime($filename, $default = 'application/octet-stream') {
if (!isset($this->_Mime)) {
$this->_Mime = new Mime();
}
$mime = $this->_Mime->detectMimeType($filename);
// Some environments falsely return the default too fast, better fallback to extension here
if (!$mime || $mime === $default) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mime = $this->_Mime->getMimeTypeByAlias($ext);
}
return $mime;
} | [
"protected",
"function",
"_getMime",
"(",
"$",
"filename",
",",
"$",
"default",
"=",
"'application/octet-stream'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Mime",
")",
")",
"{",
"$",
"this",
"->",
"_Mime",
"=",
"new",
"Mime",
"(",
... | Try to find mimetype by file extension
@param string $filename File name
@param string $default default MimeType
@return string Mimetype (falls back to `application/octet-stream`) | [
"Try",
"to",
"find",
"mimetype",
"by",
"file",
"extension"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Mailer/Email.php#L484-L495 | train |
dereuromark/cakephp-tools | src/Utility/L10n.php | L10n.map | public function map($mixed = null) {
if (is_array($mixed)) {
$result = [];
foreach ($mixed as $_mixed) {
$_result = $this->map($_mixed);
if ($_result) {
$result[$_mixed] = $_result;
}
}
return $result;
}
if (is_string($mixed)) {
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
return array_search($mixed, $this->_l10nMap);
}
if (isset($this->_l10nMap[$mixed])) {
return $this->_l10nMap[$mixed];
}
return false;
}
return $this->_l10nMap;
} | php | public function map($mixed = null) {
if (is_array($mixed)) {
$result = [];
foreach ($mixed as $_mixed) {
$_result = $this->map($_mixed);
if ($_result) {
$result[$_mixed] = $_result;
}
}
return $result;
}
if (is_string($mixed)) {
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
return array_search($mixed, $this->_l10nMap);
}
if (isset($this->_l10nMap[$mixed])) {
return $this->_l10nMap[$mixed];
}
return false;
}
return $this->_l10nMap;
} | [
"public",
"function",
"map",
"(",
"$",
"mixed",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mixed",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mixed",
"as",
"$",
"_mixed",
")",
"{",
"$",
"_result",
"=",... | Attempts to find locale for language, or language for locale
@param string|array|null $mixed 2/3 char string (language/locale), array of those strings, or null
@return string|array|bool string language/locale, array of those values, whole map as an array,
or false when language/locale doesn't exist | [
"Attempts",
"to",
"find",
"locale",
"for",
"language",
"or",
"language",
"for",
"locale"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/L10n.php#L277-L298 | train |
dereuromark/cakephp-tools | src/Utility/L10n.php | L10n.catalog | public function catalog($language = null) {
if (is_array($language)) {
$result = [];
foreach ($language as $_language) {
$_result = $this->catalog($_language);
if ($_result) {
$result[$_language] = $_result;
}
}
return $result;
}
if (is_string($language)) {
if (isset($this->_l10nCatalog[$language])) {
return $this->_l10nCatalog[$language];
}
if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
return $this->_l10nCatalog[$this->_l10nMap[$language]];
}
return false;
}
return $this->_l10nCatalog;
} | php | public function catalog($language = null) {
if (is_array($language)) {
$result = [];
foreach ($language as $_language) {
$_result = $this->catalog($_language);
if ($_result) {
$result[$_language] = $_result;
}
}
return $result;
}
if (is_string($language)) {
if (isset($this->_l10nCatalog[$language])) {
return $this->_l10nCatalog[$language];
}
if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
return $this->_l10nCatalog[$this->_l10nMap[$language]];
}
return false;
}
return $this->_l10nCatalog;
} | [
"public",
"function",
"catalog",
"(",
"$",
"language",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"language",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"language",
"as",
"$",
"_language",
")",
"{",
"$",
"... | Attempts to find catalog record for requested language
@param string|array|null $language String requested language, array of requested languages, or null for whole catalog
@return array|bool array catalog record for requested language, array of catalog records, whole catalog,
or false when language doesn't exist | [
"Attempts",
"to",
"find",
"catalog",
"record",
"for",
"requested",
"language"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/L10n.php#L307-L328 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.setConfig | public static function setConfig($options = []) {
$config = $options + (array)Configure::read('Localization');
foreach ($config as $key => $value) {
$key = '_' . $key;
if (!isset(static::${$key})) {
continue;
}
static::${$key} = $value;
}
} | php | public static function setConfig($options = []) {
$config = $options + (array)Configure::read('Localization');
foreach ($config as $key => $value) {
$key = '_' . $key;
if (!isset(static::${$key})) {
continue;
}
static::${$key} = $value;
}
} | [
"public",
"static",
"function",
"setConfig",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"$",
"options",
"+",
"(",
"array",
")",
"Configure",
"::",
"read",
"(",
"'Localization'",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$... | Correct the default values according to localization
@param array $options
@return void
@deprecated Should not be used anymore with 3.x functionality? | [
"Correct",
"the",
"default",
"values",
"according",
"to",
"localization"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L38-L47 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.currency | public static function currency($number, $currency = null, array $options = []) {
$defaults = [
'positive' => '+', 'signed' => false
];
$options += $defaults;
$sign = '';
if ($number > 0 && !empty($options['signed'])) {
$sign = $options['positive'];
}
return $sign . parent::currency($number, $currency, $options);
} | php | public static function currency($number, $currency = null, array $options = []) {
$defaults = [
'positive' => '+', 'signed' => false
];
$options += $defaults;
$sign = '';
if ($number > 0 && !empty($options['signed'])) {
$sign = $options['positive'];
}
return $sign . parent::currency($number, $currency, $options);
} | [
"public",
"static",
"function",
"currency",
"(",
"$",
"number",
",",
"$",
"currency",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'positive'",
"=>",
"'+'",
",",
"'signed'",
"=>",
"false",
"]",
";",
... | Overwrite to allow
- signed: true/false
@param float $number
@param string|null $currency
@param array $options
@return string | [
"Overwrite",
"to",
"allow"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L154-L164 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.average | public static function average($values, $precision = 0) {
if (empty($values)) {
return 0.0;
}
return round(array_sum($values) / count($values), $precision);
} | php | public static function average($values, $precision = 0) {
if (empty($values)) {
return 0.0;
}
return round(array_sum($values) / count($values), $precision);
} | [
"public",
"static",
"function",
"average",
"(",
"$",
"values",
",",
"$",
"precision",
"=",
"0",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"return",
"0.0",
";",
"}",
"return",
"round",
"(",
"array_sum",
"(",
"$",
"values",
")"... | Get the rounded average.
@param array $values Values: int or float values
@param int $precision
@return float Average | [
"Get",
"the",
"rounded",
"average",
"."
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L189-L194 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.roundTo | public static function roundTo($number, $increment = 1.0) {
$precision = static::getDecimalPlaces($increment);
$res = round($number, $precision);
if ($precision <= 0) {
$res = (int)$res;
}
return $res;
} | php | public static function roundTo($number, $increment = 1.0) {
$precision = static::getDecimalPlaces($increment);
$res = round($number, $precision);
if ($precision <= 0) {
$res = (int)$res;
}
return $res;
} | [
"public",
"static",
"function",
"roundTo",
"(",
"$",
"number",
",",
"$",
"increment",
"=",
"1.0",
")",
"{",
"$",
"precision",
"=",
"static",
"::",
"getDecimalPlaces",
"(",
"$",
"increment",
")",
";",
"$",
"res",
"=",
"round",
"(",
"$",
"number",
",",
... | Round value.
@param float $number
@param float $increment
@return float result | [
"Round",
"value",
"."
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L203-L210 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.getDecimalPlaces | public static function getDecimalPlaces($number) {
$decimalPlaces = 0;
while ($number > 1 && $number != 0) {
$number /= 10;
$decimalPlaces -= 1;
}
while ($number < 1 && $number != 0) {
$number *= 10;
$decimalPlaces += 1;
}
return $decimalPlaces;
} | php | public static function getDecimalPlaces($number) {
$decimalPlaces = 0;
while ($number > 1 && $number != 0) {
$number /= 10;
$decimalPlaces -= 1;
}
while ($number < 1 && $number != 0) {
$number *= 10;
$decimalPlaces += 1;
}
return $decimalPlaces;
} | [
"public",
"static",
"function",
"getDecimalPlaces",
"(",
"$",
"number",
")",
"{",
"$",
"decimalPlaces",
"=",
"0",
";",
"while",
"(",
"$",
"number",
">",
"1",
"&&",
"$",
"number",
"!=",
"0",
")",
"{",
"$",
"number",
"/=",
"10",
";",
"$",
"decimalPlace... | Get decimal places
@param float $number
@return int decimalPlaces | [
"Get",
"decimal",
"places"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L240-L251 | train |
dereuromark/cakephp-tools | src/Utility/Number.php | Number.isFloatEqual | public static function isFloatEqual($x, $y, $precision = 0.0000001) {
return ($x + $precision >= $y) && ($x - $precision <= $y);
} | php | public static function isFloatEqual($x, $y, $precision = 0.0000001) {
return ($x + $precision >= $y) && ($x - $precision <= $y);
} | [
"public",
"static",
"function",
"isFloatEqual",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"precision",
"=",
"0.0000001",
")",
"{",
"return",
"(",
"$",
"x",
"+",
"$",
"precision",
">=",
"$",
"y",
")",
"&&",
"(",
"$",
"x",
"-",
"$",
"precision",
"<="... | Can compare two float values
@link http://php.net/manual/en/language.types.float.php
@param float $x
@param float $y
@param float $precision
@return bool | [
"Can",
"compare",
"two",
"float",
"values"
] | 6242560dc77e0d9e5ebb4325ead05565e7a361a3 | https://github.com/dereuromark/cakephp-tools/blob/6242560dc77e0d9e5ebb4325ead05565e7a361a3/src/Utility/Number.php#L262-L264 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.