repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/RoleController.php | RoleController.destroy | public function destroy($id)
{
$this->roles->findOrFail($id)->delete();
return \Redirect::route('admin.roles.index', [
])->withMessage(trans('acl::role.roles-controller-successfully_deleted'));
} | php | public function destroy($id)
{
$this->roles->findOrFail($id)->delete();
return \Redirect::route('admin.roles.index', [
])->withMessage(trans('acl::role.roles-controller-successfully_deleted'));
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"roles",
"->",
"findOrFail",
"(",
"$",
"id",
")",
"->",
"delete",
"(",
")",
";",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.roles.index'",
",",
"[",
"]",
")",
"->",
"withMessage",
"(",
"trans",
"(",
"'acl::role.roles-controller-successfully_deleted'",
")",
")",
";",
"}"
] | Remove the specified resource from storage.
@param int $id
@return \Illuminate\Http\RedirectResponse | [
"Remove",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/RoleController.php#L110-L115 |
Ocramius/OcraDiCompiler | src/OcraDiCompiler/Mvc/Service/ControllerPluginManagerFactory.php | ControllerPluginManagerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
$plugins = new $pluginManagerClass;
$plugins->setServiceLocator($serviceLocator);
$configuration = $serviceLocator->get('Config');
if (isset($configuration['di']) && $serviceLocator->has('Di')) {
$di = $serviceLocator->get('Di');
$plugins->addAbstractFactory(
new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI)
);
}
return $plugins;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
$plugins = new $pluginManagerClass;
$plugins->setServiceLocator($serviceLocator);
$configuration = $serviceLocator->get('Config');
if (isset($configuration['di']) && $serviceLocator->has('Di')) {
$di = $serviceLocator->get('Di');
$plugins->addAbstractFactory(
new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI)
);
}
return $plugins;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"pluginManagerClass",
"=",
"static",
"::",
"PLUGIN_MANAGER_CLASS",
";",
"$",
"plugins",
"=",
"new",
"$",
"pluginManagerClass",
";",
"$",
"plugins",
"->",
"setServiceLocator",
"(",
"$",
"serviceLocator",
")",
";",
"$",
"configuration",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"configuration",
"[",
"'di'",
"]",
")",
"&&",
"$",
"serviceLocator",
"->",
"has",
"(",
"'Di'",
")",
")",
"{",
"$",
"di",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Di'",
")",
";",
"$",
"plugins",
"->",
"addAbstractFactory",
"(",
"new",
"DiAbstractServiceFactory",
"(",
"$",
"di",
",",
"DiAbstractServiceFactory",
"::",
"USE_SL_BEFORE_DI",
")",
")",
";",
"}",
"return",
"$",
"plugins",
";",
"}"
] | Create and return the MVC controller plugin manager
@param ServiceLocatorInterface $serviceLocator
@return \Zend\Mvc\Controller\PluginManager | [
"Create",
"and",
"return",
"the",
"MVC",
"controller",
"plugin",
"manager"
] | train | https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Mvc/Service/ControllerPluginManagerFactory.php#L32-L47 |
afrittella/back-project | src/app/Http/Requests/UserEdit.php | UserEdit.rules | public function rules()
{
//$userRepository = new UserRepository($this->app);
$user = $this->users->findBy('id', $this->route('user'));
return [
'username' => 'required|max:255|unique:users,username,'.$user->id,
'email' => 'required|email|max:255|unique:users,email,'.$user->id,
];
} | php | public function rules()
{
//$userRepository = new UserRepository($this->app);
$user = $this->users->findBy('id', $this->route('user'));
return [
'username' => 'required|max:255|unique:users,username,'.$user->id,
'email' => 'required|email|max:255|unique:users,email,'.$user->id,
];
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"//$userRepository = new UserRepository($this->app);",
"$",
"user",
"=",
"$",
"this",
"->",
"users",
"->",
"findBy",
"(",
"'id'",
",",
"$",
"this",
"->",
"route",
"(",
"'user'",
")",
")",
";",
"return",
"[",
"'username'",
"=>",
"'required|max:255|unique:users,username,'",
".",
"$",
"user",
"->",
"id",
",",
"'email'",
"=>",
"'required|email|max:255|unique:users,email,'",
".",
"$",
"user",
"->",
"id",
",",
"]",
";",
"}"
] | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Http/Requests/UserEdit.php#L34-L44 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserRoleQuery) {
return $criteria;
}
$query = new UserRoleQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserRoleQuery) {
return $criteria;
}
$query = new UserRoleQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"UserRoleQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"UserRoleQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Returns a new UserRoleQuery object.
@param string $modelAlias The alias of a model in the query
@param UserRoleQuery|Criteria $criteria Optional Criteria to build the query from
@return UserRoleQuery | [
"Returns",
"a",
"new",
"UserRoleQuery",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L77-L89 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.filterByPrimaryKey | public function filterByPrimaryKey($key)
{
$this->addUsingAlias(UserRolePeer::USER_ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(UserRolePeer::ROLE_ID, $key[1], Criteria::EQUAL);
return $this;
} | php | public function filterByPrimaryKey($key)
{
$this->addUsingAlias(UserRolePeer::USER_ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(UserRolePeer::ROLE_ID, $key[1], Criteria::EQUAL);
return $this;
} | [
"public",
"function",
"filterByPrimaryKey",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"USER_ID",
",",
"$",
"key",
"[",
"0",
"]",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"key",
"[",
"1",
"]",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Filter the query by primary key
@param mixed $key Primary key to use for the query
@return UserRoleQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"primary",
"key"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L211-L217 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.filterByPrimaryKeys | public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(UserRolePeer::USER_ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(UserRolePeer::ROLE_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
} | php | public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(UserRolePeer::USER_ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(UserRolePeer::ROLE_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
} | [
"public",
"function",
"filterByPrimaryKeys",
"(",
"$",
"keys",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"return",
"$",
"this",
"->",
"add",
"(",
"null",
",",
"'1<>1'",
",",
"Criteria",
"::",
"CUSTOM",
")",
";",
"}",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"cton0",
"=",
"$",
"this",
"->",
"getNewCriterion",
"(",
"UserRolePeer",
"::",
"USER_ID",
",",
"$",
"key",
"[",
"0",
"]",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"$",
"cton1",
"=",
"$",
"this",
"->",
"getNewCriterion",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"key",
"[",
"1",
"]",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"$",
"cton0",
"->",
"addAnd",
"(",
"$",
"cton1",
")",
";",
"$",
"this",
"->",
"addOr",
"(",
"$",
"cton0",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Filter the query by a list of primary keys
@param array $keys The list of primary key to use for the query
@return UserRoleQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"list",
"of",
"primary",
"keys"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L226-L239 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.filterByRoleId | public function filterByRoleId($roleId = null, $comparison = null)
{
if (is_array($roleId)) {
$useMinMax = false;
if (isset($roleId['min'])) {
$this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($roleId['max'])) {
$this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId, $comparison);
} | php | public function filterByRoleId($roleId = null, $comparison = null)
{
if (is_array($roleId)) {
$useMinMax = false;
if (isset($roleId['min'])) {
$this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($roleId['max'])) {
$this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserRolePeer::ROLE_ID, $roleId, $comparison);
} | [
"public",
"function",
"filterByRoleId",
"(",
"$",
"roleId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"roleId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"roleId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"roleId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"roleId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"roleId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"roleId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the role_id column
Example usage:
<code>
$query->filterByRoleId(1234); // WHERE role_id = 1234
$query->filterByRoleId(array(12, 34)); // WHERE role_id IN (12, 34)
$query->filterByRoleId(array('min' => 12)); // WHERE role_id >= 12
$query->filterByRoleId(array('max' => 12)); // WHERE role_id <= 12
</code>
@see filterByRole()
@param mixed $roleId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserRoleQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"role_id",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L306-L327 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.filterByRole | public function filterByRole($role, $comparison = null)
{
if ($role instanceof Role) {
return $this
->addUsingAlias(UserRolePeer::ROLE_ID, $role->getId(), $comparison);
} elseif ($role instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(UserRolePeer::ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByRole() only accepts arguments of type Role or PropelCollection');
}
} | php | public function filterByRole($role, $comparison = null)
{
if ($role instanceof Role) {
return $this
->addUsingAlias(UserRolePeer::ROLE_ID, $role->getId(), $comparison);
} elseif ($role instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(UserRolePeer::ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByRole() only accepts arguments of type Role or PropelCollection');
}
} | [
"public",
"function",
"filterByRole",
"(",
"$",
"role",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"role",
"instanceof",
"Role",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"role",
"->",
"getId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"role",
"instanceof",
"PropelObjectCollection",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"role",
"->",
"toKeyValue",
"(",
"'PrimaryKey'",
",",
"'Id'",
")",
",",
"$",
"comparison",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByRole() only accepts arguments of type Role or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related Role object
@param Role|PropelObjectCollection $role The related object(s) to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserRoleQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"Role",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L414-L429 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.useRoleQuery | public function useRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRole($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Role', '\Slashworks\BackendBundle\Model\RoleQuery');
} | php | public function useRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRole($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Role', '\Slashworks\BackendBundle\Model\RoleQuery');
} | [
"public",
"function",
"useRoleQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinRole",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'Role'",
",",
"'\\Slashworks\\BackendBundle\\Model\\RoleQuery'",
")",
";",
"}"
] | Use the Role relation Role object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Slashworks\BackendBundle\Model\RoleQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"Role",
"relation",
"Role",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L474-L479 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php | BaseUserRoleQuery.prune | public function prune($userRole = null)
{
if ($userRole) {
$this->addCond('pruneCond0', $this->getAliasedColName(UserRolePeer::USER_ID), $userRole->getUserId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(UserRolePeer::ROLE_ID), $userRole->getRoleId(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
} | php | public function prune($userRole = null)
{
if ($userRole) {
$this->addCond('pruneCond0', $this->getAliasedColName(UserRolePeer::USER_ID), $userRole->getUserId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(UserRolePeer::ROLE_ID), $userRole->getRoleId(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
} | [
"public",
"function",
"prune",
"(",
"$",
"userRole",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"userRole",
")",
"{",
"$",
"this",
"->",
"addCond",
"(",
"'pruneCond0'",
",",
"$",
"this",
"->",
"getAliasedColName",
"(",
"UserRolePeer",
"::",
"USER_ID",
")",
",",
"$",
"userRole",
"->",
"getUserId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"$",
"this",
"->",
"addCond",
"(",
"'pruneCond1'",
",",
"$",
"this",
"->",
"getAliasedColName",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
")",
",",
"$",
"userRole",
"->",
"getRoleId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"$",
"this",
"->",
"combine",
"(",
"array",
"(",
"'pruneCond0'",
",",
"'pruneCond1'",
")",
",",
"Criteria",
"::",
"LOGICAL_OR",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Exclude object from result
@param UserRole $userRole Object to remove from the list of results
@return UserRoleQuery The current query, for fluid interface | [
"Exclude",
"object",
"from",
"result"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L488-L497 |
askupasoftware/amarkal | Log/Logger.php | Logger.log | public function log($level, $message, array $context = array())
{
$message = $this->formatMessage($level, $message, $context);
$this->write($message);
} | php | public function log($level, $message, array $context = array())
{
$message = $this->formatMessage($level, $message, $context);
$this->write($message);
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"formatMessage",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"message",
")",
";",
"}"
] | Logs with an arbitrary level.
@param mixed $level
@param string $message
@param array $context
@return null | [
"Logs",
"with",
"an",
"arbitrary",
"level",
"."
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Log/Logger.php#L100-L104 |
askupasoftware/amarkal | Log/Logger.php | Logger.write | public function write($message)
{
if (! is_null($this->fileHandle)) {
if (fwrite($this->fileHandle, $message) === false) {
throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
}
}
} | php | public function write($message)
{
if (! is_null($this->fileHandle)) {
if (fwrite($this->fileHandle, $message) === false) {
throw new RuntimeException('The file could not be written to. Check that appropriate permissions have been set.');
}
}
} | [
"public",
"function",
"write",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"fileHandle",
")",
")",
"{",
"if",
"(",
"fwrite",
"(",
"$",
"this",
"->",
"fileHandle",
",",
"$",
"message",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'The file could not be written to. Check that appropriate permissions have been set.'",
")",
";",
"}",
"}",
"}"
] | Writes a line to the log without prepending a status or timestamp
@param string $line Line to write to the log
@return void | [
"Writes",
"a",
"line",
"to",
"the",
"log",
"without",
"prepending",
"a",
"status",
"or",
"timestamp"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Log/Logger.php#L112-L119 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.copy | public static function copy($names, $from, &$to)
{
if (is_array($from) && is_array($to)) {
foreach ($names as $key) {
if (isset($from[$key]) && !isset($to[$key])) {
$to[$key] = static::getValue($from, $key);
}
}
}
return $to;
} | php | public static function copy($names, $from, &$to)
{
if (is_array($from) && is_array($to)) {
foreach ($names as $key) {
if (isset($from[$key]) && !isset($to[$key])) {
$to[$key] = static::getValue($from, $key);
}
}
}
return $to;
} | [
"public",
"static",
"function",
"copy",
"(",
"$",
"names",
",",
"$",
"from",
",",
"&",
"$",
"to",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"from",
")",
"&&",
"is_array",
"(",
"$",
"to",
")",
")",
"{",
"foreach",
"(",
"$",
"names",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"from",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"to",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"to",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"getValue",
"(",
"$",
"from",
",",
"$",
"key",
")",
";",
"}",
"}",
"}",
"return",
"$",
"to",
";",
"}"
] | Copies the values from one option array to another.
@param array $names the items names to copy.
@param array $from the items to copy from.
@param array $to the items to copy to.
@return array with copied items. | [
"Copies",
"the",
"values",
"from",
"one",
"option",
"array",
"to",
"another",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L26-L36 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.move | public static function move($names, &$from, &$to)
{
if (is_array($from) && is_array($to)) {
foreach ($names as $key) {
if (isset($from[$key]) && !isset($to[$key])) {
$to[$key] = static::getValue($from, $key);
$moved[$key] = static::removeValue($from, $key);
}
}
}
return $moved;
} | php | public static function move($names, &$from, &$to)
{
if (is_array($from) && is_array($to)) {
foreach ($names as $key) {
if (isset($from[$key]) && !isset($to[$key])) {
$to[$key] = static::getValue($from, $key);
$moved[$key] = static::removeValue($from, $key);
}
}
}
return $moved;
} | [
"public",
"static",
"function",
"move",
"(",
"$",
"names",
",",
"&",
"$",
"from",
",",
"&",
"$",
"to",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"from",
")",
"&&",
"is_array",
"(",
"$",
"to",
")",
")",
"{",
"foreach",
"(",
"$",
"names",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"from",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"to",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"to",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"getValue",
"(",
"$",
"from",
",",
"$",
"key",
")",
";",
"$",
"moved",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"removeValue",
"(",
"$",
"from",
",",
"$",
"key",
")",
";",
"}",
"}",
"}",
"return",
"$",
"moved",
";",
"}"
] | Moves the item values from one array to another.
@param array $names the item names to move.
@param array $from the values to move from.
@param array $to the items to move to.
@return array with moved items. | [
"Moves",
"the",
"item",
"values",
"from",
"one",
"array",
"to",
"another",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L45-L56 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.addValue | public static function addValue($key, $value, &$array, $glue = ' ')
{
if (isset($array[$key])) {
if (!is_array($array[$key]))
$array[$key] = explode($glue, $array[$key]);
$array[$key][] = $value;
$array[$key] = array_unique($array[$key]);
$array[$key] = implode($glue, $array[$key]);
} else
$array[$key] = $value;
return $array;
} | php | public static function addValue($key, $value, &$array, $glue = ' ')
{
if (isset($array[$key])) {
if (!is_array($array[$key]))
$array[$key] = explode($glue, $array[$key]);
$array[$key][] = $value;
$array[$key] = array_unique($array[$key]);
$array[$key] = implode($glue, $array[$key]);
} else
$array[$key] = $value;
return $array;
} | [
"public",
"static",
"function",
"addValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"&",
"$",
"array",
",",
"$",
"glue",
"=",
"' '",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"explode",
"(",
"$",
"glue",
",",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"$",
"array",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"array_unique",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"implode",
"(",
"$",
"glue",
",",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"array",
";",
"}"
] | Adds a new option to the given array. If the key does not exists, it will create one, if it exists it will append
the value and also makes sure the uniqueness of them.
@param string $key the key name at the array
@param string $value the value to add / append
@param array $array the options to modify
@param string $glue how the values will be joined
@return array | [
"Adds",
"a",
"new",
"option",
"to",
"the",
"given",
"array",
".",
"If",
"the",
"key",
"does",
"not",
"exists",
"it",
"will",
"create",
"one",
"if",
"it",
"exists",
"it",
"will",
"append",
"the",
"value",
"and",
"also",
"makes",
"sure",
"the",
"uniqueness",
"of",
"them",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L98-L109 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.getValue | public static function getValue($array, $key, $default = null)
{
if ($key instanceof \Closure) {
return $key($array, $default);
} elseif (is_array($array)) {
return isset($array[$key]) || array_key_exists($key, $array) ? $array[$key] : $default;
} else {
return $array->$key;
}
} | php | public static function getValue($array, $key, $default = null)
{
if ($key instanceof \Closure) {
return $key($array, $default);
} elseif (is_array($array)) {
return isset($array[$key]) || array_key_exists($key, $array) ? $array[$key] : $default;
} else {
return $array->$key;
}
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"instanceof",
"\\",
"Closure",
")",
"{",
"return",
"$",
"key",
"(",
"$",
"array",
",",
"$",
"default",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
"?",
"$",
"array",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}",
"else",
"{",
"return",
"$",
"array",
"->",
"$",
"key",
";",
"}",
"}"
] | Retrieves the value of an array element or object property with the given key or property name.
If the key does not exist in the array, the default value will be returned instead.
@param array|object $array array or object to extract value from
@param string|\Closure $key key name of the array element, or property name of the object,
or an anonymous function returning the value. The anonymous function signature should be:
`function($array, $defaultValue)`.
@param mixed $default the default value to be returned if the specified key does not exist
@return mixed the value of the | [
"Retrieves",
"the",
"value",
"of",
"an",
"array",
"element",
"or",
"object",
"property",
"with",
"the",
"given",
"key",
"or",
"property",
"name",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"in",
"the",
"array",
"the",
"default",
"value",
"will",
"be",
"returned",
"instead",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L122-L131 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.removeValue | public static function removeValue(&$array, $key, $default = null)
{
if (is_array($array)) {
$value = static::getValue($array, $key, $default);
unset($array[$key]);
return static::value($value);
}
return self::value($default);
} | php | public static function removeValue(&$array, $key, $default = null)
{
if (is_array($array)) {
$value = static::getValue($array, $key, $default);
unset($array[$key]);
return static::value($value);
}
return self::value($default);
} | [
"public",
"static",
"function",
"removeValue",
"(",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"getValue",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"return",
"static",
"::",
"value",
"(",
"$",
"value",
")",
";",
"}",
"return",
"self",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}"
] | Removes an item from the given options and returns the value.
If no key is found, then default value will be returned.
@param $array
@param $key
@param null $default
@return mixed|null | [
"Removes",
"an",
"item",
"from",
"the",
"given",
"options",
"and",
"returns",
"the",
"value",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L143-L151 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.pluck | public static function pluck($array, $key)
{
return array_map(
function ($v) use ($key) {
return is_object($v) ? $v->$key : $v[$key];
},
$array
);
} | php | public static function pluck($array, $key)
{
return array_map(
function ($v) use ($key) {
return is_object($v) ? $v->$key : $v[$key];
},
$array
);
} | [
"public",
"static",
"function",
"pluck",
"(",
"$",
"array",
",",
"$",
"key",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"key",
")",
"{",
"return",
"is_object",
"(",
"$",
"v",
")",
"?",
"$",
"v",
"->",
"$",
"key",
":",
"$",
"v",
"[",
"$",
"key",
"]",
";",
"}",
",",
"$",
"array",
")",
";",
"}"
] | Pluck an array of values from an array.
@param array $array
@param string $key
@return array | [
"Pluck",
"an",
"array",
"of",
"values",
"from",
"an",
"array",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L182-L191 |
2amigos/yiifoundation | helpers/ArrayHelper.php | ArrayHelper.map | public static function map(array $array, $callback, $on_nonscalar = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
$args = array($value, $callback, $on_nonscalar);
$array[$key] = call_user_func_array(array(__CLASS__, __FUNCTION__), $args);
} else {
if (is_scalar($value) || $on_nonscalar) {
$array[$key] = call_user_func($callback, $value);
}
}
}
return $array;
} | php | public static function map(array $array, $callback, $on_nonscalar = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
$args = array($value, $callback, $on_nonscalar);
$array[$key] = call_user_func_array(array(__CLASS__, __FUNCTION__), $args);
} else {
if (is_scalar($value) || $on_nonscalar) {
$array[$key] = call_user_func($callback, $value);
}
}
}
return $array;
} | [
"public",
"static",
"function",
"map",
"(",
"array",
"$",
"array",
",",
"$",
"callback",
",",
"$",
"on_nonscalar",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"$",
"value",
",",
"$",
"callback",
",",
"$",
"on_nonscalar",
")",
";",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"call_user_func_array",
"(",
"array",
"(",
"__CLASS__",
",",
"__FUNCTION__",
")",
",",
"$",
"args",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"$",
"on_nonscalar",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] | Returns an array containing all the elements of arr1 after applying
the callback function to each one.
Credits to Util.php
@param array $array an array to run through the callback function
@param $callback Callback function to run for each element in each array
@param bool $on_nonscalar whether or not to call the callback function on nonscalar values (objects, resr, etc)
@return array
@link https://github.com/brandonwamboldt/utilphp/blob/master/util.php | [
"Returns",
"an",
"array",
"containing",
"all",
"the",
"elements",
"of",
"arr1",
"after",
"applying",
"the",
"callback",
"function",
"to",
"each",
"one",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L347-L361 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.getWeek | public static function getWeek($week = null): string
{
$week = $week ? $week : date('w');
switch ($week) {
case 'Sunday':
return Yii::t('yuncms', 'Sunday');
break;
case 'Monday':
return Yii::t('yuncms', 'Monday');
break;
case 'Tuesday':
return Yii::t('yuncms', 'Tuesday');
break;
case 'Wednesday':
return Yii::t('yuncms', 'Wednesday');
break;
case 'Thursday':
return Yii::t('yuncms', 'Thursday');
break;
case 'Friday':
return Yii::t('yuncms', 'Friday');
break;
case 'Saturday':
return Yii::t('yuncms', 'Saturday');
break;
}
return 'N/A';
} | php | public static function getWeek($week = null): string
{
$week = $week ? $week : date('w');
switch ($week) {
case 'Sunday':
return Yii::t('yuncms', 'Sunday');
break;
case 'Monday':
return Yii::t('yuncms', 'Monday');
break;
case 'Tuesday':
return Yii::t('yuncms', 'Tuesday');
break;
case 'Wednesday':
return Yii::t('yuncms', 'Wednesday');
break;
case 'Thursday':
return Yii::t('yuncms', 'Thursday');
break;
case 'Friday':
return Yii::t('yuncms', 'Friday');
break;
case 'Saturday':
return Yii::t('yuncms', 'Saturday');
break;
}
return 'N/A';
} | [
"public",
"static",
"function",
"getWeek",
"(",
"$",
"week",
"=",
"null",
")",
":",
"string",
"{",
"$",
"week",
"=",
"$",
"week",
"?",
"$",
"week",
":",
"date",
"(",
"'w'",
")",
";",
"switch",
"(",
"$",
"week",
")",
"{",
"case",
"'Sunday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Sunday'",
")",
";",
"break",
";",
"case",
"'Monday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Monday'",
")",
";",
"break",
";",
"case",
"'Tuesday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Tuesday'",
")",
";",
"break",
";",
"case",
"'Wednesday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Wednesday'",
")",
";",
"break",
";",
"case",
"'Thursday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Thursday'",
")",
";",
"break",
";",
"case",
"'Friday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Friday'",
")",
";",
"break",
";",
"case",
"'Saturday'",
":",
"return",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Saturday'",
")",
";",
"break",
";",
"}",
"return",
"'N/A'",
";",
"}"
] | 获取星期
@param int $week 星期,默认为当前时间获取
@return string | [
"获取星期"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L61-L88 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.isLeapYear | public static function isLeapYear($year = null): bool
{
$year = $year ? $year : date('Y');
return ($year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0);
} | php | public static function isLeapYear($year = null): bool
{
$year = $year ? $year : date('Y');
return ($year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0);
} | [
"public",
"static",
"function",
"isLeapYear",
"(",
"$",
"year",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"year",
"=",
"$",
"year",
"?",
"$",
"year",
":",
"date",
"(",
"'Y'",
")",
";",
"return",
"(",
"$",
"year",
"%",
"4",
"==",
"0",
"&&",
"$",
"year",
"%",
"100",
"!=",
"0",
"||",
"$",
"year",
"%",
"400",
"==",
"0",
")",
";",
"}"
] | 判断是否为闰年
@param int $year 年份,默认为当前年份
@return bool | [
"判断是否为闰年"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L96-L100 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.getDaysInYear | public static function getDaysInYear($year = null): int
{
$year = $year ? $year : date('Y');
return self::isLeapYear($year) ? 366 : 365;
} | php | public static function getDaysInYear($year = null): int
{
$year = $year ? $year : date('Y');
return self::isLeapYear($year) ? 366 : 365;
} | [
"public",
"static",
"function",
"getDaysInYear",
"(",
"$",
"year",
"=",
"null",
")",
":",
"int",
"{",
"$",
"year",
"=",
"$",
"year",
"?",
"$",
"year",
":",
"date",
"(",
"'Y'",
")",
";",
"return",
"self",
"::",
"isLeapYear",
"(",
"$",
"year",
")",
"?",
"366",
":",
"365",
";",
"}"
] | 获取一年中有多少天
@param int $year 年份,默认为当前年份
@return int | [
"获取一年中有多少天"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L108-L112 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.dateAdd | public static function dateAdd($interval, $value, $dateTime = null, $format = null): string
{
$dateTime = $dateTime ? $dateTime : date('Y-m-d H:i:s');
$date = getdate(self::getTimestamp($dateTime));
switch ($interval) {
case 'Y' : // 年
$date ['year'] += $value;
break;
case 'Q' : // 季度
$date ['mon'] += ($value * 3);
break;
case 'M' : // 月
$date ['mon'] += $value;
break;
case 'W' : // 星期
$date ['mday'] += ($value * 7);
break;
case 'D' : // 日
$date ['mday'] += $value;
break;
case 'H' : // 时
$date ['hours'] += $value;
break;
case 'N' : // 分
$date ['minutes'] += $value;
break;
case 'S' : // 秒
default :
$date ['seconds'] += $value;
break;
}
return date($format, mktime($date ['hours'], $date ['minutes'], $date ['seconds'], $date ['mon'], $date ['mday'], $date ['year']));
} | php | public static function dateAdd($interval, $value, $dateTime = null, $format = null): string
{
$dateTime = $dateTime ? $dateTime : date('Y-m-d H:i:s');
$date = getdate(self::getTimestamp($dateTime));
switch ($interval) {
case 'Y' : // 年
$date ['year'] += $value;
break;
case 'Q' : // 季度
$date ['mon'] += ($value * 3);
break;
case 'M' : // 月
$date ['mon'] += $value;
break;
case 'W' : // 星期
$date ['mday'] += ($value * 7);
break;
case 'D' : // 日
$date ['mday'] += $value;
break;
case 'H' : // 时
$date ['hours'] += $value;
break;
case 'N' : // 分
$date ['minutes'] += $value;
break;
case 'S' : // 秒
default :
$date ['seconds'] += $value;
break;
}
return date($format, mktime($date ['hours'], $date ['minutes'], $date ['seconds'], $date ['mon'], $date ['mday'], $date ['year']));
} | [
"public",
"static",
"function",
"dateAdd",
"(",
"$",
"interval",
",",
"$",
"value",
",",
"$",
"dateTime",
"=",
"null",
",",
"$",
"format",
"=",
"null",
")",
":",
"string",
"{",
"$",
"dateTime",
"=",
"$",
"dateTime",
"?",
"$",
"dateTime",
":",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"date",
"=",
"getdate",
"(",
"self",
"::",
"getTimestamp",
"(",
"$",
"dateTime",
")",
")",
";",
"switch",
"(",
"$",
"interval",
")",
"{",
"case",
"'Y'",
":",
"// 年",
"$",
"date",
"[",
"'year'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"case",
"'Q'",
":",
"// 季度",
"$",
"date",
"[",
"'mon'",
"]",
"+=",
"(",
"$",
"value",
"*",
"3",
")",
";",
"break",
";",
"case",
"'M'",
":",
"// 月",
"$",
"date",
"[",
"'mon'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"case",
"'W'",
":",
"// 星期",
"$",
"date",
"[",
"'mday'",
"]",
"+=",
"(",
"$",
"value",
"*",
"7",
")",
";",
"break",
";",
"case",
"'D'",
":",
"// 日",
"$",
"date",
"[",
"'mday'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"case",
"'H'",
":",
"// 时",
"$",
"date",
"[",
"'hours'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"case",
"'N'",
":",
"// 分",
"$",
"date",
"[",
"'minutes'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"case",
"'S'",
":",
"// 秒",
"default",
":",
"$",
"date",
"[",
"'seconds'",
"]",
"+=",
"$",
"value",
";",
"break",
";",
"}",
"return",
"date",
"(",
"$",
"format",
",",
"mktime",
"(",
"$",
"date",
"[",
"'hours'",
"]",
",",
"$",
"date",
"[",
"'minutes'",
"]",
",",
"$",
"date",
"[",
"'seconds'",
"]",
",",
"$",
"date",
"[",
"'mon'",
"]",
",",
"$",
"date",
"[",
"'mday'",
"]",
",",
"$",
"date",
"[",
"'year'",
"]",
")",
")",
";",
"}"
] | 返回指定日期在一段时间间隔时间后的日期
@param string $interval 时间间隔类型,(Y:年、Q:季度、M:月、W:星期、D:日期、H:时、N:分、S:秒)
@param int $value 时间间隔数值,数值为正数获取未来的时间,数值为负数获取过去的时间
@param string $dateTime 日期
@param string $format 返回的日期转换格式
@return string 返回追加后的日期 | [
"返回指定日期在一段时间间隔时间后的日期"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L272-L304 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.getDaysByMonthsOfYear | public static function getDaysByMonthsOfYear($year = null): array
{
$year = $year ? $year : date('Y');
$months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (self::isLeapYear($year)) $months [1] = 29;
return $months;
} | php | public static function getDaysByMonthsOfYear($year = null): array
{
$year = $year ? $year : date('Y');
$months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (self::isLeapYear($year)) $months [1] = 29;
return $months;
} | [
"public",
"static",
"function",
"getDaysByMonthsOfYear",
"(",
"$",
"year",
"=",
"null",
")",
":",
"array",
"{",
"$",
"year",
"=",
"$",
"year",
"?",
"$",
"year",
":",
"date",
"(",
"'Y'",
")",
";",
"$",
"months",
"=",
"[",
"31",
",",
"28",
",",
"31",
",",
"30",
",",
"31",
",",
"30",
",",
"31",
",",
"31",
",",
"30",
",",
"31",
",",
"30",
",",
"31",
"]",
";",
"if",
"(",
"self",
"::",
"isLeapYear",
"(",
"$",
"year",
")",
")",
"$",
"months",
"[",
"1",
"]",
"=",
"29",
";",
"return",
"$",
"months",
";",
"}"
] | 根据年份获取每个月的天数
@param int $year 年份
@return array 月份天数数组 | [
"根据年份获取每个月的天数"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L312-L318 |
yuncms/framework | src/helpers/DateHelper.php | DateHelper.getDaysByMonth | public static function getDaysByMonth($month, $year): int
{
$months = self::getDaysByMonthsOfYear($year);
$value = $months [$month - 1];
return !$value ? 0 : $value;
} | php | public static function getDaysByMonth($month, $year): int
{
$months = self::getDaysByMonthsOfYear($year);
$value = $months [$month - 1];
return !$value ? 0 : $value;
} | [
"public",
"static",
"function",
"getDaysByMonth",
"(",
"$",
"month",
",",
"$",
"year",
")",
":",
"int",
"{",
"$",
"months",
"=",
"self",
"::",
"getDaysByMonthsOfYear",
"(",
"$",
"year",
")",
";",
"$",
"value",
"=",
"$",
"months",
"[",
"$",
"month",
"-",
"1",
"]",
";",
"return",
"!",
"$",
"value",
"?",
"0",
":",
"$",
"value",
";",
"}"
] | 返回某年的某个月有多少天
@param int $month 月份
@param int $year 年份
@return int 月份天数 | [
"返回某年的某个月有多少天"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/DateHelper.php#L327-L332 |
dandisy/laravel-generator | src/Common/CommandData.php | CommandData.addLogs | private function addLogs()
{
$createdBy = new GeneratorField();
$createdBy->name = 'created_by';
$createdBy->parseDBType('integer');
$createdBy->parseOptions('if,n');
$this->fields[] = $createdBy;
$updatedBy = new GeneratorField();
$updatedBy->name = 'updated_by';
$updatedBy->parseDBType('integer');
$updatedBy->parseOptions('if,n'); // edited by dandisy
$this->fields[] = $updatedBy;
} | php | private function addLogs()
{
$createdBy = new GeneratorField();
$createdBy->name = 'created_by';
$createdBy->parseDBType('integer');
$createdBy->parseOptions('if,n');
$this->fields[] = $createdBy;
$updatedBy = new GeneratorField();
$updatedBy->name = 'updated_by';
$updatedBy->parseDBType('integer');
$updatedBy->parseOptions('if,n'); // edited by dandisy
$this->fields[] = $updatedBy;
} | [
"private",
"function",
"addLogs",
"(",
")",
"{",
"$",
"createdBy",
"=",
"new",
"GeneratorField",
"(",
")",
";",
"$",
"createdBy",
"->",
"name",
"=",
"'created_by'",
";",
"$",
"createdBy",
"->",
"parseDBType",
"(",
"'integer'",
")",
";",
"$",
"createdBy",
"->",
"parseOptions",
"(",
"'if,n'",
")",
";",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"createdBy",
";",
"$",
"updatedBy",
"=",
"new",
"GeneratorField",
"(",
")",
";",
"$",
"updatedBy",
"->",
"name",
"=",
"'updated_by'",
";",
"$",
"updatedBy",
"->",
"parseDBType",
"(",
"'integer'",
")",
";",
"$",
"updatedBy",
"->",
"parseOptions",
"(",
"'if,n'",
")",
";",
"// edited by dandisy",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"updatedBy",
";",
"}"
] | added by dandisy | [
"added",
"by",
"dandisy"
] | train | https://github.com/dandisy/laravel-generator/blob/742797c8483bc88b54b6302a516a9a85eeb8579b/src/Common/CommandData.php#L184-L197 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Form/Type/EntitySelect2Type.php | EntitySelect2Type.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['attr']['autocomplete'] = 'off';
if (array_key_exists('searchRouteName', $options)) {
$view->vars['attr']['data-source'] = $this->router->generate($options['searchRouteName'], $options['searchRouteParams']).'?property='.$options['property'];
}
$object = $form->getData();
if ($object != null && $object instanceof $options['class']) {
$getterI = 'get'.ucfirst($options['primaryKey']);
$getterP = 'get'.ucfirst($options['property']);
if (method_exists($object, $getterI) && method_exists($object, $getterP)) {
$view->vars['attr']['data-initSelection'] = '{"id":"'.$object->$getterI().'","text":"'.str_replace('"', '\"', $object->$getterP()).'"}';
} elseif (method_exists($object, $getterI) && method_exists($object, '__toString')) {
$view->vars['attr']['data-initSelection'] = '{"id":"'.$object->$getterI().'","text":"'.str_replace('"', '\"', ''.$object).'"}';
}
}
if (array_key_exists('required', $options) && $options['required'] == false && array_key_exists('placeholder', $options) && empty($options['placeholder'])) {
throw new \Exception('Le placeholder est obligatoire pour pouvoir supprimer la valeur');
}
foreach ($this->copyProperty as $optionProperty => $attrProperty) {
if (array_key_exists($optionProperty, $options)) {
$view->vars['attr'][$attrProperty] = $options[$optionProperty];
}
}
parent::buildView($view, $form, $options);
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['attr']['autocomplete'] = 'off';
if (array_key_exists('searchRouteName', $options)) {
$view->vars['attr']['data-source'] = $this->router->generate($options['searchRouteName'], $options['searchRouteParams']).'?property='.$options['property'];
}
$object = $form->getData();
if ($object != null && $object instanceof $options['class']) {
$getterI = 'get'.ucfirst($options['primaryKey']);
$getterP = 'get'.ucfirst($options['property']);
if (method_exists($object, $getterI) && method_exists($object, $getterP)) {
$view->vars['attr']['data-initSelection'] = '{"id":"'.$object->$getterI().'","text":"'.str_replace('"', '\"', $object->$getterP()).'"}';
} elseif (method_exists($object, $getterI) && method_exists($object, '__toString')) {
$view->vars['attr']['data-initSelection'] = '{"id":"'.$object->$getterI().'","text":"'.str_replace('"', '\"', ''.$object).'"}';
}
}
if (array_key_exists('required', $options) && $options['required'] == false && array_key_exists('placeholder', $options) && empty($options['placeholder'])) {
throw new \Exception('Le placeholder est obligatoire pour pouvoir supprimer la valeur');
}
foreach ($this->copyProperty as $optionProperty => $attrProperty) {
if (array_key_exists($optionProperty, $options)) {
$view->vars['attr'][$attrProperty] = $options[$optionProperty];
}
}
parent::buildView($view, $form, $options);
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'attr'",
"]",
"[",
"'autocomplete'",
"]",
"=",
"'off'",
";",
"if",
"(",
"array_key_exists",
"(",
"'searchRouteName'",
",",
"$",
"options",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'attr'",
"]",
"[",
"'data-source'",
"]",
"=",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"options",
"[",
"'searchRouteName'",
"]",
",",
"$",
"options",
"[",
"'searchRouteParams'",
"]",
")",
".",
"'?property='",
".",
"$",
"options",
"[",
"'property'",
"]",
";",
"}",
"$",
"object",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"$",
"object",
"!=",
"null",
"&&",
"$",
"object",
"instanceof",
"$",
"options",
"[",
"'class'",
"]",
")",
"{",
"$",
"getterI",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"options",
"[",
"'primaryKey'",
"]",
")",
";",
"$",
"getterP",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"options",
"[",
"'property'",
"]",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"object",
",",
"$",
"getterI",
")",
"&&",
"method_exists",
"(",
"$",
"object",
",",
"$",
"getterP",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'attr'",
"]",
"[",
"'data-initSelection'",
"]",
"=",
"'{\"id\":\"'",
".",
"$",
"object",
"->",
"$",
"getterI",
"(",
")",
".",
"'\",\"text\":\"'",
".",
"str_replace",
"(",
"'\"'",
",",
"'\\\"'",
",",
"$",
"object",
"->",
"$",
"getterP",
"(",
")",
")",
".",
"'\"}'",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"object",
",",
"$",
"getterI",
")",
"&&",
"method_exists",
"(",
"$",
"object",
",",
"'__toString'",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'attr'",
"]",
"[",
"'data-initSelection'",
"]",
"=",
"'{\"id\":\"'",
".",
"$",
"object",
"->",
"$",
"getterI",
"(",
")",
".",
"'\",\"text\":\"'",
".",
"str_replace",
"(",
"'\"'",
",",
"'\\\"'",
",",
"''",
".",
"$",
"object",
")",
".",
"'\"}'",
";",
"}",
"}",
"if",
"(",
"array_key_exists",
"(",
"'required'",
",",
"$",
"options",
")",
"&&",
"$",
"options",
"[",
"'required'",
"]",
"==",
"false",
"&&",
"array_key_exists",
"(",
"'placeholder'",
",",
"$",
"options",
")",
"&&",
"empty",
"(",
"$",
"options",
"[",
"'placeholder'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Le placeholder est obligatoire pour pouvoir supprimer la valeur'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"copyProperty",
"as",
"$",
"optionProperty",
"=>",
"$",
"attrProperty",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"optionProperty",
",",
"$",
"options",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'attr'",
"]",
"[",
"$",
"attrProperty",
"]",
"=",
"$",
"options",
"[",
"$",
"optionProperty",
"]",
";",
"}",
"}",
"parent",
"::",
"buildView",
"(",
"$",
"view",
",",
"$",
"form",
",",
"$",
"options",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Form/Type/EntitySelect2Type.php#L77-L106 |
uthando-cms/uthando-dompdf | src/UthandoDomPdf/Form/PdfTextLineFieldSet.php | PdfTextLineFieldSet.init | public function init()
{
$this->add([
'name' => 'text',
'type' => Text::class,
'options' => [
'label' => 'Line Text',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'position',
'type' => Select::class,
'options' => [
'label' => 'Text Position',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
'label_attributes' => [
'class' => 'col-md-4',
],
'value_options' => [
'center' => 'Center',
'left' => 'Left',
'right' => 'Right',
],
'column-size' => 'md-8',
],
]);
$this->add([
'type' => PdfTextLineFontFieldSet::class,
'name' => 'font',
'options' => [
'label' => 'Font',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
],
'attributes' => [
'class' => 'col-md-12',
],
]);
} | php | public function init()
{
$this->add([
'name' => 'text',
'type' => Text::class,
'options' => [
'label' => 'Line Text',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'position',
'type' => Select::class,
'options' => [
'label' => 'Text Position',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
'label_attributes' => [
'class' => 'col-md-4',
],
'value_options' => [
'center' => 'Center',
'left' => 'Left',
'right' => 'Right',
],
'column-size' => 'md-8',
],
]);
$this->add([
'type' => PdfTextLineFontFieldSet::class,
'name' => 'font',
'options' => [
'label' => 'Font',
'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL,
],
'attributes' => [
'class' => 'col-md-12',
],
]);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'text'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Line Text'",
",",
"'twb-layout'",
"=>",
"TwbBundleForm",
"::",
"LAYOUT_HORIZONTAL",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'position'",
",",
"'type'",
"=>",
"Select",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Text Position'",
",",
"'twb-layout'",
"=>",
"TwbBundleForm",
"::",
"LAYOUT_HORIZONTAL",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"'value_options'",
"=>",
"[",
"'center'",
"=>",
"'Center'",
",",
"'left'",
"=>",
"'Left'",
",",
"'right'",
"=>",
"'Right'",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'type'",
"=>",
"PdfTextLineFontFieldSet",
"::",
"class",
",",
"'name'",
"=>",
"'font'",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Font'",
",",
"'twb-layout'",
"=>",
"TwbBundleForm",
"::",
"LAYOUT_HORIZONTAL",
",",
"]",
",",
"'attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
")",
";",
"}"
] | Set up elements | [
"Set",
"up",
"elements"
] | train | https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/Form/PdfTextLineFieldSet.php#L45-L89 |
webforge-labs/psc-cms | lib/Psc/Net/HTTP/Response.php | Response.output | public function output($flags = 0x00003) {
if (($flags & self::OUTPUT_HEADER) == self::OUTPUT_HEADER) {
$this->sendHeaders();
}
if ($this->outputClosure instanceof \Closure) {
$c = $this->outputClosure;
$c();
return;
}
if (($flags & self::OUTPUT_BODY) == self::OUTPUT_BODY) {
print $this->body;
}
} | php | public function output($flags = 0x00003) {
if (($flags & self::OUTPUT_HEADER) == self::OUTPUT_HEADER) {
$this->sendHeaders();
}
if ($this->outputClosure instanceof \Closure) {
$c = $this->outputClosure;
$c();
return;
}
if (($flags & self::OUTPUT_BODY) == self::OUTPUT_BODY) {
print $this->body;
}
} | [
"public",
"function",
"output",
"(",
"$",
"flags",
"=",
"0x00003",
")",
"{",
"if",
"(",
"(",
"$",
"flags",
"&",
"self",
"::",
"OUTPUT_HEADER",
")",
"==",
"self",
"::",
"OUTPUT_HEADER",
")",
"{",
"$",
"this",
"->",
"sendHeaders",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"outputClosure",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"outputClosure",
";",
"$",
"c",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"(",
"$",
"flags",
"&",
"self",
"::",
"OUTPUT_BODY",
")",
"==",
"self",
"::",
"OUTPUT_BODY",
")",
"{",
"print",
"$",
"this",
"->",
"body",
";",
"}",
"}"
] | Sendet die Headers und gibt den Body aus
@param bitmap $flags Default: (self::OUTPUT_HEADER | self::OUTPUT_BODY) | [
"Sendet",
"die",
"Headers",
"und",
"gibt",
"den",
"Body",
"aus"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/Response.php#L146-L160 |
phpmob/changmin | src/PhpMob/ChangMinBundle/Factory/TaxonFactory.php | TaxonFactory.createWidthParent | public function createWidthParent(?TaxonInterface $parent): TaxonInterface
{
$taxon = $this->createNew();
$taxon->setParent($parent);
return $taxon;
} | php | public function createWidthParent(?TaxonInterface $parent): TaxonInterface
{
$taxon = $this->createNew();
$taxon->setParent($parent);
return $taxon;
} | [
"public",
"function",
"createWidthParent",
"(",
"?",
"TaxonInterface",
"$",
"parent",
")",
":",
"TaxonInterface",
"{",
"$",
"taxon",
"=",
"$",
"this",
"->",
"createNew",
"(",
")",
";",
"$",
"taxon",
"->",
"setParent",
"(",
"$",
"parent",
")",
";",
"return",
"$",
"taxon",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/ChangMinBundle/Factory/TaxonFactory.php#L60-L66 |
webtown-php/KunstmaanExtensionBundle | src/Form/PageParts/InsertPagePagePartAdminType.php | InsertPagePagePartAdminType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$locale = $this->requestStack->getMasterRequest()->getLocale();
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
parent::buildForm($builder, $options);
$builder->add('node', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', [
'label' => 'wt_kuma_extension.insert_page.form.label.inserted_node',
'class' => 'Kunstmaan\NodeBundle\Entity\Node',
'expanded' => false,
'multiple' => false,
'required' => true,
'property' => function (Node $choice) use ($locale, $em) {
/** @var AbstractPage $page */
$page = $choice->getNodeTranslation($locale, true)->getRef($em);
return str_repeat('-', $choice->getLevel() * 2) . ' ' . $page->getPageTitle();
},
]);
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$locale = $this->requestStack->getMasterRequest()->getLocale();
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
parent::buildForm($builder, $options);
$builder->add('node', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', [
'label' => 'wt_kuma_extension.insert_page.form.label.inserted_node',
'class' => 'Kunstmaan\NodeBundle\Entity\Node',
'expanded' => false,
'multiple' => false,
'required' => true,
'property' => function (Node $choice) use ($locale, $em) {
/** @var AbstractPage $page */
$page = $choice->getNodeTranslation($locale, true)->getRef($em);
return str_repeat('-', $choice->getLevel() * 2) . ' ' . $page->getPageTitle();
},
]);
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"/** @var EntityManager $em */",
"$",
"em",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
")",
";",
"parent",
"::",
"buildForm",
"(",
"$",
"builder",
",",
"$",
"options",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'node'",
",",
"'Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType'",
",",
"[",
"'label'",
"=>",
"'wt_kuma_extension.insert_page.form.label.inserted_node'",
",",
"'class'",
"=>",
"'Kunstmaan\\NodeBundle\\Entity\\Node'",
",",
"'expanded'",
"=>",
"false",
",",
"'multiple'",
"=>",
"false",
",",
"'required'",
"=>",
"true",
",",
"'property'",
"=>",
"function",
"(",
"Node",
"$",
"choice",
")",
"use",
"(",
"$",
"locale",
",",
"$",
"em",
")",
"{",
"/** @var AbstractPage $page */",
"$",
"page",
"=",
"$",
"choice",
"->",
"getNodeTranslation",
"(",
"$",
"locale",
",",
"true",
")",
"->",
"getRef",
"(",
"$",
"em",
")",
";",
"return",
"str_repeat",
"(",
"'-'",
",",
"$",
"choice",
"->",
"getLevel",
"(",
")",
"*",
"2",
")",
".",
"' '",
".",
"$",
"page",
"->",
"getPageTitle",
"(",
")",
";",
"}",
",",
"]",
")",
";",
"}"
] | Builds the form.
This method is called for each type in the hierarchy starting form the
top most type. Type extensions can further modify the form.
@param FormBuilderInterface $builder The form builder
@param array $options The options
@see FormTypeExtensionInterface::buildForm() | [
"Builds",
"the",
"form",
"."
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Form/PageParts/InsertPagePagePartAdminType.php#L67-L87 |
webtown-php/KunstmaanExtensionBundle | src/Form/PageParts/InsertPagePagePartAdminType.php | InsertPagePagePartAdminType.finishView | public function finishView(FormView $view, FormInterface $form, array $options)
{
$data = $form->getData();
if ($data instanceof InsertPagePagePart) {
$this->validateParentPage();
$reflections = [];
$nodeFormView = $view->children['node'];
/** @var ChoiceView $choice */
foreach ($nodeFormView->vars['choices'] as $choice) {
/** @var Node $currentData */
$currentData = $choice->data;
$entityCls = $currentData->getRefEntityName();
if (!array_key_exists($entityCls, $reflections)) {
$reflections[$entityCls] = new \ReflectionClass($entityCls);
}
// only the pages with the right interface are selectable
if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) {
$choice->attr['disabled'] = 'disabled';
}
}
}
} | php | public function finishView(FormView $view, FormInterface $form, array $options)
{
$data = $form->getData();
if ($data instanceof InsertPagePagePart) {
$this->validateParentPage();
$reflections = [];
$nodeFormView = $view->children['node'];
/** @var ChoiceView $choice */
foreach ($nodeFormView->vars['choices'] as $choice) {
/** @var Node $currentData */
$currentData = $choice->data;
$entityCls = $currentData->getRefEntityName();
if (!array_key_exists($entityCls, $reflections)) {
$reflections[$entityCls] = new \ReflectionClass($entityCls);
}
// only the pages with the right interface are selectable
if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) {
$choice->attr['disabled'] = 'disabled';
}
}
}
} | [
"public",
"function",
"finishView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"data",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"$",
"data",
"instanceof",
"InsertPagePagePart",
")",
"{",
"$",
"this",
"->",
"validateParentPage",
"(",
")",
";",
"$",
"reflections",
"=",
"[",
"]",
";",
"$",
"nodeFormView",
"=",
"$",
"view",
"->",
"children",
"[",
"'node'",
"]",
";",
"/** @var ChoiceView $choice */",
"foreach",
"(",
"$",
"nodeFormView",
"->",
"vars",
"[",
"'choices'",
"]",
"as",
"$",
"choice",
")",
"{",
"/** @var Node $currentData */",
"$",
"currentData",
"=",
"$",
"choice",
"->",
"data",
";",
"$",
"entityCls",
"=",
"$",
"currentData",
"->",
"getRefEntityName",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"entityCls",
",",
"$",
"reflections",
")",
")",
"{",
"$",
"reflections",
"[",
"$",
"entityCls",
"]",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entityCls",
")",
";",
"}",
"// only the pages with the right interface are selectable",
"if",
"(",
"!",
"$",
"reflections",
"[",
"$",
"entityCls",
"]",
"->",
"implementsInterface",
"(",
"InsertablePageInterface",
"::",
"class",
")",
")",
"{",
"$",
"choice",
"->",
"attr",
"[",
"'disabled'",
"]",
"=",
"'disabled'",
";",
"}",
"}",
"}",
"}"
] | We want to set disable the parent page to prevent infinity insert cycle. If it is an edit page, we can disable this
from form's data.
@param FormView $view
@param FormInterface $form
@param array $options | [
"We",
"want",
"to",
"set",
"disable",
"the",
"parent",
"page",
"to",
"prevent",
"infinity",
"insert",
"cycle",
".",
"If",
"it",
"is",
"an",
"edit",
"page",
"we",
"can",
"disable",
"this",
"from",
"form",
"s",
"data",
"."
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Form/PageParts/InsertPagePagePartAdminType.php#L97-L122 |
webtown-php/KunstmaanExtensionBundle | src/Form/PageParts/InsertPagePagePartAdminType.php | InsertPagePagePartAdminType.validateParentPage | protected function validateParentPage()
{
$request = $this->requestStack->getMasterRequest();
// the node which the pagepart belongs to
if ($request->query->has('pageid') && $request->query->has('pageclassname')) {
$repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node');
$node = $repo->getNodeForIdAndEntityname(
$request->query->get('pageid'),
$request->query->get('pageclassname')
);
$pageReflection = new \ReflectionClass($node->getRefEntityName());
// if the current page implements the interface, then it is forbidden to insert anything beneath
if ($pageReflection->implementsInterface(InsertablePageInterface::class)) {
$currentContext = $this->requestStack->getMasterRequest()->get('context');
$page = $pageReflection->newInstanceWithoutConstructor();
// get pagepart configurations for the current page
$pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page);
foreach ($pagePartConfigs as $config) {
if ($config->getContext() === $currentContext) {
foreach ($config->getPossiblePagePartTypes() as $pagePartType) {
if ($pagePartType['class'] === InsertPagePagePart::class) {
throw new \LogicException(
sprintf(
'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.',
$pageReflection->getName(),
InsertPagePagePart::class,
InsertablePageInterface::class,
$currentContext
));
}
}
}
}
}
}
} | php | protected function validateParentPage()
{
$request = $this->requestStack->getMasterRequest();
// the node which the pagepart belongs to
if ($request->query->has('pageid') && $request->query->has('pageclassname')) {
$repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node');
$node = $repo->getNodeForIdAndEntityname(
$request->query->get('pageid'),
$request->query->get('pageclassname')
);
$pageReflection = new \ReflectionClass($node->getRefEntityName());
// if the current page implements the interface, then it is forbidden to insert anything beneath
if ($pageReflection->implementsInterface(InsertablePageInterface::class)) {
$currentContext = $this->requestStack->getMasterRequest()->get('context');
$page = $pageReflection->newInstanceWithoutConstructor();
// get pagepart configurations for the current page
$pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page);
foreach ($pagePartConfigs as $config) {
if ($config->getContext() === $currentContext) {
foreach ($config->getPossiblePagePartTypes() as $pagePartType) {
if ($pagePartType['class'] === InsertPagePagePart::class) {
throw new \LogicException(
sprintf(
'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.',
$pageReflection->getName(),
InsertPagePagePart::class,
InsertablePageInterface::class,
$currentContext
));
}
}
}
}
}
}
} | [
"protected",
"function",
"validateParentPage",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
";",
"// the node which the pagepart belongs to",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'pageid'",
")",
"&&",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'pageclassname'",
")",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
"'KunstmaanNodeBundle:Node'",
")",
";",
"$",
"node",
"=",
"$",
"repo",
"->",
"getNodeForIdAndEntityname",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'pageid'",
")",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'pageclassname'",
")",
")",
";",
"$",
"pageReflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"node",
"->",
"getRefEntityName",
"(",
")",
")",
";",
"// if the current page implements the interface, then it is forbidden to insert anything beneath",
"if",
"(",
"$",
"pageReflection",
"->",
"implementsInterface",
"(",
"InsertablePageInterface",
"::",
"class",
")",
")",
"{",
"$",
"currentContext",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
"->",
"get",
"(",
"'context'",
")",
";",
"$",
"page",
"=",
"$",
"pageReflection",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"// get pagepart configurations for the current page",
"$",
"pagePartConfigs",
"=",
"$",
"this",
"->",
"pagePartConfigReader",
"->",
"getPagePartAdminConfigurators",
"(",
"$",
"page",
")",
";",
"foreach",
"(",
"$",
"pagePartConfigs",
"as",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getContext",
"(",
")",
"===",
"$",
"currentContext",
")",
"{",
"foreach",
"(",
"$",
"config",
"->",
"getPossiblePagePartTypes",
"(",
")",
"as",
"$",
"pagePartType",
")",
"{",
"if",
"(",
"$",
"pagePartType",
"[",
"'class'",
"]",
"===",
"InsertPagePagePart",
"::",
"class",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The %s page must not allow %s as possible page part, because it implements %s! You must modify the \"%s\" context.'",
",",
"$",
"pageReflection",
"->",
"getName",
"(",
")",
",",
"InsertPagePagePart",
"::",
"class",
",",
"InsertablePageInterface",
"::",
"class",
",",
"$",
"currentContext",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
] | Check if the page part is insertable into the current page.
@throws \LogicException | [
"Check",
"if",
"the",
"page",
"part",
"is",
"insertable",
"into",
"the",
"current",
"page",
"."
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Form/PageParts/InsertPagePagePartAdminType.php#L129-L169 |
yuncms/framework | src/sms/gateways/QcloudGateway.php | QcloudGateway.generateSign | protected function generateSign($params, $random)
{
ksort($params);
return hash('sha256', sprintf(
'appkey=%s&random=%s&time=%s&mobile=%s',
$this->appKey,
$random,
$params['time'],
$params['tel']['mobile']
), false);
} | php | protected function generateSign($params, $random)
{
ksort($params);
return hash('sha256', sprintf(
'appkey=%s&random=%s&time=%s&mobile=%s',
$this->appKey,
$random,
$params['time'],
$params['tel']['mobile']
), false);
} | [
"protected",
"function",
"generateSign",
"(",
"$",
"params",
",",
"$",
"random",
")",
"{",
"ksort",
"(",
"$",
"params",
")",
";",
"return",
"hash",
"(",
"'sha256'",
",",
"sprintf",
"(",
"'appkey=%s&random=%s&time=%s&mobile=%s'",
",",
"$",
"this",
"->",
"appKey",
",",
"$",
"random",
",",
"$",
"params",
"[",
"'time'",
"]",
",",
"$",
"params",
"[",
"'tel'",
"]",
"[",
"'mobile'",
"]",
")",
",",
"false",
")",
";",
"}"
] | Generate Sign.
@param array $params
@param string $random
@return string | [
"Generate",
"Sign",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/gateways/QcloudGateway.php#L106-L116 |
left-right/center | src/console/Refresh.php | Refresh.fire | public function fire()
{
$tables = config('center.tables');
$joining_tables = [];
//dd($tables);
foreach ($tables as $table) {
//create if doesn't exist, every table gets an id
if (!Schema::hasTable($table->name)) {
Schema::create($table->name, function($t) {
$t->increments('id');
});
}
foreach ($table->fields as $field) {
if ($field->type == 'checkboxes') {
//create linking table
if (!Schema::hasTable($field->name)) {
Schema::create($field->name, function($t) {
$t->increments('id');
});
}
$column = RowController::formatKeyColumn($table->name);
if (!Schema::hasColumn($field->name, $column)) {
Schema::table($field->name, function($t) use($column) {
$t->integer($column);
});
}
$column = RowController::formatKeyColumn($field->source);
if (!Schema::hasColumn($field->name, $column)) {
Schema::table($field->name, function($t) use($column) {
$t->integer($column);
});
}
} else {
//create column
Schema::table($table->name, function($t) use($table, $field) {
//set type
switch ($field->type) {
//boolean
case 'checkbox':
eval('$t->boolean($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//strings
case 'address':
case 'color':
case 'country':
case 'email':
case 'password':
case 'phone':
case 'slug':
case 'stripe_charge':
case 'stripe_customer':
case 'string':
case 'url':
case 'us_state':
case 'zip':
if (!isset($field->maxlength)) $field->maxlength = 255;
eval('$t->string($field->name, $field->maxlength)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//date
case 'date':
eval('$t->date($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//datetime
case 'datetime':
eval('$t->datetime($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//time
case 'time':
eval('$t->time($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//text
case 'html':
case 'text':
eval('$t->text($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//foreign key
case 'image':
case 'integer':
case 'select':
case 'user':
eval('$t->integer($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//decimal
case 'money':
eval('$t->decimal($field->name, 5, 2)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//latitude
case 'latitude':
eval('$t->decimal($field->name, 11, 8)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//latitude
case 'longitude':
eval('$t->decimal($field->name, 11, 8)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
default:
trigger_error($field->type . ' not supported yet!');
}
//remove unused columns?
if ($table->keep_clean) {
$columns = Schema::getColumnListing($table->name);
$fields = array_keys((array) $table->fields);
$columns = array_diff($columns, $fields, ['id']);
foreach ($columns as $column) $t->dropColumn($column);
}
});
}
}
}
$this->comment(PHP_EOL . trans('center::site.refresh_success') . PHP_EOL);
} | php | public function fire()
{
$tables = config('center.tables');
$joining_tables = [];
//dd($tables);
foreach ($tables as $table) {
//create if doesn't exist, every table gets an id
if (!Schema::hasTable($table->name)) {
Schema::create($table->name, function($t) {
$t->increments('id');
});
}
foreach ($table->fields as $field) {
if ($field->type == 'checkboxes') {
//create linking table
if (!Schema::hasTable($field->name)) {
Schema::create($field->name, function($t) {
$t->increments('id');
});
}
$column = RowController::formatKeyColumn($table->name);
if (!Schema::hasColumn($field->name, $column)) {
Schema::table($field->name, function($t) use($column) {
$t->integer($column);
});
}
$column = RowController::formatKeyColumn($field->source);
if (!Schema::hasColumn($field->name, $column)) {
Schema::table($field->name, function($t) use($column) {
$t->integer($column);
});
}
} else {
//create column
Schema::table($table->name, function($t) use($table, $field) {
//set type
switch ($field->type) {
//boolean
case 'checkbox':
eval('$t->boolean($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//strings
case 'address':
case 'color':
case 'country':
case 'email':
case 'password':
case 'phone':
case 'slug':
case 'stripe_charge':
case 'stripe_customer':
case 'string':
case 'url':
case 'us_state':
case 'zip':
if (!isset($field->maxlength)) $field->maxlength = 255;
eval('$t->string($field->name, $field->maxlength)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//date
case 'date':
eval('$t->date($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//datetime
case 'datetime':
eval('$t->datetime($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//time
case 'time':
eval('$t->time($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//text
case 'html':
case 'text':
eval('$t->text($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//foreign key
case 'image':
case 'integer':
case 'select':
case 'user':
eval('$t->integer($field->name)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//decimal
case 'money':
eval('$t->decimal($field->name, 5, 2)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//latitude
case 'latitude':
eval('$t->decimal($field->name, 11, 8)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
//latitude
case 'longitude':
eval('$t->decimal($field->name, 11, 8)' .
($field->required ? '' : '->nullable()') .
(!Schema::hasColumn($table->name, $field->name) ? '' : '->change()') .
'; ');
break;
default:
trigger_error($field->type . ' not supported yet!');
}
//remove unused columns?
if ($table->keep_clean) {
$columns = Schema::getColumnListing($table->name);
$fields = array_keys((array) $table->fields);
$columns = array_diff($columns, $fields, ['id']);
foreach ($columns as $column) $t->dropColumn($column);
}
});
}
}
}
$this->comment(PHP_EOL . trans('center::site.refresh_success') . PHP_EOL);
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"tables",
"=",
"config",
"(",
"'center.tables'",
")",
";",
"$",
"joining_tables",
"=",
"[",
"]",
";",
"//dd($tables);",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"//create if doesn't exist, every table gets an id",
"if",
"(",
"!",
"Schema",
"::",
"hasTable",
"(",
"$",
"table",
"->",
"name",
")",
")",
"{",
"Schema",
"::",
"create",
"(",
"$",
"table",
"->",
"name",
",",
"function",
"(",
"$",
"t",
")",
"{",
"$",
"t",
"->",
"increments",
"(",
"'id'",
")",
";",
"}",
")",
";",
"}",
"foreach",
"(",
"$",
"table",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"type",
"==",
"'checkboxes'",
")",
"{",
"//create linking table",
"if",
"(",
"!",
"Schema",
"::",
"hasTable",
"(",
"$",
"field",
"->",
"name",
")",
")",
"{",
"Schema",
"::",
"create",
"(",
"$",
"field",
"->",
"name",
",",
"function",
"(",
"$",
"t",
")",
"{",
"$",
"t",
"->",
"increments",
"(",
"'id'",
")",
";",
"}",
")",
";",
"}",
"$",
"column",
"=",
"RowController",
"::",
"formatKeyColumn",
"(",
"$",
"table",
"->",
"name",
")",
";",
"if",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"field",
"->",
"name",
",",
"$",
"column",
")",
")",
"{",
"Schema",
"::",
"table",
"(",
"$",
"field",
"->",
"name",
",",
"function",
"(",
"$",
"t",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"t",
"->",
"integer",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"$",
"column",
"=",
"RowController",
"::",
"formatKeyColumn",
"(",
"$",
"field",
"->",
"source",
")",
";",
"if",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"field",
"->",
"name",
",",
"$",
"column",
")",
")",
"{",
"Schema",
"::",
"table",
"(",
"$",
"field",
"->",
"name",
",",
"function",
"(",
"$",
"t",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"t",
"->",
"integer",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"}",
"else",
"{",
"//create column",
"Schema",
"::",
"table",
"(",
"$",
"table",
"->",
"name",
",",
"function",
"(",
"$",
"t",
")",
"use",
"(",
"$",
"table",
",",
"$",
"field",
")",
"{",
"//set type",
"switch",
"(",
"$",
"field",
"->",
"type",
")",
"{",
"//boolean",
"case",
"'checkbox'",
":",
"eval",
"(",
"'$t->boolean($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//strings",
"case",
"'address'",
":",
"case",
"'color'",
":",
"case",
"'country'",
":",
"case",
"'email'",
":",
"case",
"'password'",
":",
"case",
"'phone'",
":",
"case",
"'slug'",
":",
"case",
"'stripe_charge'",
":",
"case",
"'stripe_customer'",
":",
"case",
"'string'",
":",
"case",
"'url'",
":",
"case",
"'us_state'",
":",
"case",
"'zip'",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"->",
"maxlength",
")",
")",
"$",
"field",
"->",
"maxlength",
"=",
"255",
";",
"eval",
"(",
"'$t->string($field->name, $field->maxlength)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//date",
"case",
"'date'",
":",
"eval",
"(",
"'$t->date($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//datetime",
"case",
"'datetime'",
":",
"eval",
"(",
"'$t->datetime($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//time",
"case",
"'time'",
":",
"eval",
"(",
"'$t->time($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//text",
"case",
"'html'",
":",
"case",
"'text'",
":",
"eval",
"(",
"'$t->text($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//foreign key",
"case",
"'image'",
":",
"case",
"'integer'",
":",
"case",
"'select'",
":",
"case",
"'user'",
":",
"eval",
"(",
"'$t->integer($field->name)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//decimal",
"case",
"'money'",
":",
"eval",
"(",
"'$t->decimal($field->name, 5, 2)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//latitude",
"case",
"'latitude'",
":",
"eval",
"(",
"'$t->decimal($field->name, 11, 8)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"//latitude",
"case",
"'longitude'",
":",
"eval",
"(",
"'$t->decimal($field->name, 11, 8)'",
".",
"(",
"$",
"field",
"->",
"required",
"?",
"''",
":",
"'->nullable()'",
")",
".",
"(",
"!",
"Schema",
"::",
"hasColumn",
"(",
"$",
"table",
"->",
"name",
",",
"$",
"field",
"->",
"name",
")",
"?",
"''",
":",
"'->change()'",
")",
".",
"'; '",
")",
";",
"break",
";",
"default",
":",
"trigger_error",
"(",
"$",
"field",
"->",
"type",
".",
"' not supported yet!'",
")",
";",
"}",
"//remove unused columns?",
"if",
"(",
"$",
"table",
"->",
"keep_clean",
")",
"{",
"$",
"columns",
"=",
"Schema",
"::",
"getColumnListing",
"(",
"$",
"table",
"->",
"name",
")",
";",
"$",
"fields",
"=",
"array_keys",
"(",
"(",
"array",
")",
"$",
"table",
"->",
"fields",
")",
";",
"$",
"columns",
"=",
"array_diff",
"(",
"$",
"columns",
",",
"$",
"fields",
",",
"[",
"'id'",
"]",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"$",
"t",
"->",
"dropColumn",
"(",
"$",
"column",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"comment",
"(",
"PHP_EOL",
".",
"trans",
"(",
"'center::site.refresh_success'",
")",
".",
"PHP_EOL",
")",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/console/Refresh.php#L41-L202 |
uthando-cms/uthando-dompdf | src/UthandoDomPdf/Form/DomPdfOptionsFieldSet.php | DomPdfOptionsFieldSet.init | public function init()
{
$this->add([
'name' => 'font_directory',
'type' => Text::class,
'options' => [
'label' => 'Font Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'font_cache_directory',
'type' => Text::class,
'options' => [
'label' => 'Cache Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'temporary_directory',
'type' => Text::class,
'options' => [
'label' => 'Temp Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'chroot',
'type' => Text::class,
'options' => [
'label' => 'Chroot',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'unicode_enabled',
'type' => Radio::class,
'options' => [
'label' => 'Enable Unicode',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_fontsubsetting',
'type' => Radio::class,
'options' => [
'label' => 'Enable Font Subsetting',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'pdf_backend',
'type' => Select::class,
'options' => [
'label' => 'PDF Backend',
'label_attributes' => [
'class' => 'col-md-4',
],
'value_options' => [
'auto' => 'auto',
'CPDF' => 'CPDF',
'PDFLib' => 'PDFLib',
'GD' => 'GD',
],
'column-size' => 'md-8',
],
]);
$this->add([
'name' => 'pdflib_license',
'type' => Textarea::class,
'options' => [
'label' => 'PDFLib License',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_media_type',
'type' => Text::class,
'options' => [
'label' => 'Default Media Type',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_paper_size',
'type' => Text::class,
'options' => [
'label' => 'Default Paper Size',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_font',
'type' => Text::class,
'options' => [
'label' => 'Default Font',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'dpi',
'type' => Number::class,
'options' => [
'label' => 'DPI Setting',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
'attributes' => [
'min' => '72',
]
]);
$this->add([
'name' => 'enable_php',
'type' => Radio::class,
'options' => [
'label' => 'Enable PHP',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_javascript',
'type' => Radio::class,
'options' => [
'label' => 'Enable JavaScript',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_remote',
'type' => Radio::class,
'options' => [
'label' => 'Enable Remote',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'log_output_file',
'type' => Text::class,
'options' => [
'label' => 'Debug Log',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'font_height_ratio',
'type' => Number::class,
'options' => [
'label' => 'Font Height Ratio',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
'attributes' => [
'min' => '0',
'step' => '0.1'
]
]);
$this->add([
'name' => 'enable_css_float',
'type' => Radio::class,
'options' => [
'label' => 'Enable CSS Float',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_html5parser',
'type' => Radio::class,
'options' => [
'label' => 'Enable HTML5 Parser',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_png',
'type' => Radio::class,
'options' => [
'label' => 'Dedug PNG',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_keep_temp',
'type' => Radio::class,
'options' => [
'label' => 'Debug Keep Temp',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_css',
'type' => Radio::class,
'options' => [
'label' => 'Debug CSS',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_lines',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Lines',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_blocks',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Blocks',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_inline',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Inline',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_padding_box',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Padding Box',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
} | php | public function init()
{
$this->add([
'name' => 'font_directory',
'type' => Text::class,
'options' => [
'label' => 'Font Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'font_cache_directory',
'type' => Text::class,
'options' => [
'label' => 'Cache Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'temporary_directory',
'type' => Text::class,
'options' => [
'label' => 'Temp Directory',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'chroot',
'type' => Text::class,
'options' => [
'label' => 'Chroot',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'unicode_enabled',
'type' => Radio::class,
'options' => [
'label' => 'Enable Unicode',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_fontsubsetting',
'type' => Radio::class,
'options' => [
'label' => 'Enable Font Subsetting',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'pdf_backend',
'type' => Select::class,
'options' => [
'label' => 'PDF Backend',
'label_attributes' => [
'class' => 'col-md-4',
],
'value_options' => [
'auto' => 'auto',
'CPDF' => 'CPDF',
'PDFLib' => 'PDFLib',
'GD' => 'GD',
],
'column-size' => 'md-8',
],
]);
$this->add([
'name' => 'pdflib_license',
'type' => Textarea::class,
'options' => [
'label' => 'PDFLib License',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_media_type',
'type' => Text::class,
'options' => [
'label' => 'Default Media Type',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_paper_size',
'type' => Text::class,
'options' => [
'label' => 'Default Paper Size',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'default_font',
'type' => Text::class,
'options' => [
'label' => 'Default Font',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'dpi',
'type' => Number::class,
'options' => [
'label' => 'DPI Setting',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
'attributes' => [
'min' => '72',
]
]);
$this->add([
'name' => 'enable_php',
'type' => Radio::class,
'options' => [
'label' => 'Enable PHP',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_javascript',
'type' => Radio::class,
'options' => [
'label' => 'Enable JavaScript',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_remote',
'type' => Radio::class,
'options' => [
'label' => 'Enable Remote',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'log_output_file',
'type' => Text::class,
'options' => [
'label' => 'Debug Log',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'font_height_ratio',
'type' => Number::class,
'options' => [
'label' => 'Font Height Ratio',
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
'attributes' => [
'min' => '0',
'step' => '0.1'
]
]);
$this->add([
'name' => 'enable_css_float',
'type' => Radio::class,
'options' => [
'label' => 'Enable CSS Float',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'enable_html5parser',
'type' => Radio::class,
'options' => [
'label' => 'Enable HTML5 Parser',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_png',
'type' => Radio::class,
'options' => [
'label' => 'Dedug PNG',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_keep_temp',
'type' => Radio::class,
'options' => [
'label' => 'Debug Keep Temp',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_css',
'type' => Radio::class,
'options' => [
'label' => 'Debug CSS',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_lines',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Lines',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_blocks',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Blocks',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_inline',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Inline',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
$this->add([
'name' => 'debug_layout_padding_box',
'type' => Radio::class,
'options' => [
'label' => 'Debug Layout Padding Box',
'value_options' => [
[
'value' => 0,
'label' => 'No',
'label_attributes' => [
'class' => 'col-md-12',
],
],
[
'value' => 1,
'label' => 'Yes',
'label_attributes' => [
'class' => 'col-md-12',
],
],
],
'column-size' => 'md-8',
'label_attributes' => [
'class' => 'col-md-4',
],
],
]);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'font_directory'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Font Directory'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'font_cache_directory'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Cache Directory'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'temporary_directory'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Temp Directory'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'chroot'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Chroot'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'unicode_enabled'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable Unicode'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_fontsubsetting'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable Font Subsetting'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'pdf_backend'",
",",
"'type'",
"=>",
"Select",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'PDF Backend'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"'value_options'",
"=>",
"[",
"'auto'",
"=>",
"'auto'",
",",
"'CPDF'",
"=>",
"'CPDF'",
",",
"'PDFLib'",
"=>",
"'PDFLib'",
",",
"'GD'",
"=>",
"'GD'",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'pdflib_license'",
",",
"'type'",
"=>",
"Textarea",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'PDFLib License'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'default_media_type'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Default Media Type'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'default_paper_size'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Default Paper Size'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'default_font'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Default Font'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'dpi'",
",",
"'type'",
"=>",
"Number",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'DPI Setting'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"'attributes'",
"=>",
"[",
"'min'",
"=>",
"'72'",
",",
"]",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_php'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable PHP'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_javascript'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable JavaScript'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_remote'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable Remote'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'log_output_file'",
",",
"'type'",
"=>",
"Text",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Log'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'font_height_ratio'",
",",
"'type'",
"=>",
"Number",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Font Height Ratio'",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"'attributes'",
"=>",
"[",
"'min'",
"=>",
"'0'",
",",
"'step'",
"=>",
"'0.1'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_css_float'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable CSS Float'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'enable_html5parser'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Enable HTML5 Parser'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_png'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Dedug PNG'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_keep_temp'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Keep Temp'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_css'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug CSS'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_layout'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Layout'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_layout_lines'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Layout Lines'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_layout_blocks'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Layout Blocks'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_layout_inline'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Layout Inline'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'debug_layout_padding_box'",
",",
"'type'",
"=>",
"Radio",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'label'",
"=>",
"'Debug Layout Padding Box'",
",",
"'value_options'",
"=>",
"[",
"[",
"'value'",
"=>",
"0",
",",
"'label'",
"=>",
"'No'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"[",
"'value'",
"=>",
"1",
",",
"'label'",
"=>",
"'Yes'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-12'",
",",
"]",
",",
"]",
",",
"]",
",",
"'column-size'",
"=>",
"'md-8'",
",",
"'label_attributes'",
"=>",
"[",
"'class'",
"=>",
"'col-md-4'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"}"
] | Set up form elements | [
"Set",
"up",
"form",
"elements"
] | train | https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/Form/DomPdfOptionsFieldSet.php#L48-L656 |
webforge-labs/psc-cms | lib/Psc/CMS/Service/EntityService.php | EntityService.doResponsibleFor | protected function doResponsibleFor(ServiceRequest $request) {
$r = $this->initRequestMatcher($request);
// nach "entities/" kommt immer ein identifier
$entityPart = $r->qmatchRx('/[a-z0-9]+/i',0);
return TRUE;
} | php | protected function doResponsibleFor(ServiceRequest $request) {
$r = $this->initRequestMatcher($request);
// nach "entities/" kommt immer ein identifier
$entityPart = $r->qmatchRx('/[a-z0-9]+/i',0);
return TRUE;
} | [
"protected",
"function",
"doResponsibleFor",
"(",
"ServiceRequest",
"$",
"request",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"initRequestMatcher",
"(",
"$",
"request",
")",
";",
"// nach \"entities/\" kommt immer ein identifier ",
"$",
"entityPart",
"=",
"$",
"r",
"->",
"qmatchRx",
"(",
"'/[a-z0-9]+/i'",
",",
"0",
")",
";",
"return",
"TRUE",
";",
"}"
] | Überprüft ob der Request zu diesem Service hört
wir sind jetzt ein gemeiner Service und behaupten, dass alles was mit "entities" anfängt zu uns gehört
das ist praktisch um z.B. abfangen zu können, dass ein AbstractEntityController fehlt (um ihn automatisch zu erstellen) | [
"Überprüft",
"ob",
"der",
"Request",
"zu",
"diesem",
"Service",
"hört"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/EntityService.php#L59-L66 |
webforge-labs/psc-cms | lib/Psc/CMS/Service/EntityService.php | EntityService.routeController | public function routeController(ServiceRequest $request) {
$r = $this->initRequestMatcher($request);
$entityPart = $r->qmatchRx('/^[a-z-0-9]+$/i',0);
if (mb_strpos($entityPart, '-') !== FALSE) {
$entityPart = Code::dashToCamelCase($entityPart);
}
// alle weiteren Parameter an den Controller weitergeben
$params = $r->getLeftParts();
if ($request->getType() === self::GET) {
$this->log('EntityPart: '.$entityPart.' '.($this->isPlural($entityPart) ? 'ist plural' : 'ist singular'), 2);
if ($this->isPlural($entityPart)) {
if ($r->part() === 'form') {
$method = 'getNewEntityFormular';
} else {
$method = 'getEntities';
A::insert($params, $request->getQuery(), 0); // query als 1. parameter
}
$entityPart = Inflector::singular($entityPart);
} else {
$method = 'getEntity';
$params = array();
$params[] = $r->shift(); // id
$params[] = count($r->getLeftParts()) > 1 ? $r->getLeftParts() : $r->shift(); // subresource
$params[] = $request->getQuery();
}
} elseif ($request->getType() === self::PUT) {
if ($r->part() === 'grid') {
$entityPart = Inflector::singular($entityPart);
$controller = $this->getEntityController($entityPart);
$method = 'saveSort';
$params = array($r->bvar($controller->getSortField(), array()));
} elseif($request->hasMeta('revision') && $request->getMeta('revision') !== 'default') {
$method = 'saveEntityAsRevision';
A::insert($params, $request->getMeta('revision'), 1);
A::insert($params, (object) $request->getBody(), 2);
} else {
$method = 'saveEntity';
A::insert($params, (object) $request->getBody(), 1); // $formData als parameter 2
}
} elseif ($request->getType() === self::PATCH) {
$method = 'patchEntity';
A::insert($params, (object) $request->getBody(), 1); // $formData als parameter 2
} elseif ($request->getType() === self::DELETE) {
$method = 'deleteEntity'; // das gibt einen "missing argument 1" fehler, wenn id fehlt, aber ka welche httpException ich hier nehmensoll, deshalb bleibt das erstmal so
} elseif ($request->getType() === self::POST) {
$entityPart = Inflector::singular($entityPart); // singular und plural okay
A::insert($params, $request->getBody(), 0); // $formData als parameter 1
if ($request->hasMeta('revision')) {
$method = 'insertEntityRevision';
A::insert($params, $request->getMeta('revision'), 0);
} else {
$method = 'insertEntity';
}
} else {
// das kann glaub ich nicht mehr passieren, weil wir jetzt alle haben: put/pust/delete/get gibts nicht noch head?
throw HTTPException::MethodNotAllowed('Die Methode: '.$request->getType().' ist für diesen Request nicht erlaubt');
}
if (!isset($controller))
$controller = $this->getEntityController($entityPart);
return array($controller, $method, $params);
} | php | public function routeController(ServiceRequest $request) {
$r = $this->initRequestMatcher($request);
$entityPart = $r->qmatchRx('/^[a-z-0-9]+$/i',0);
if (mb_strpos($entityPart, '-') !== FALSE) {
$entityPart = Code::dashToCamelCase($entityPart);
}
// alle weiteren Parameter an den Controller weitergeben
$params = $r->getLeftParts();
if ($request->getType() === self::GET) {
$this->log('EntityPart: '.$entityPart.' '.($this->isPlural($entityPart) ? 'ist plural' : 'ist singular'), 2);
if ($this->isPlural($entityPart)) {
if ($r->part() === 'form') {
$method = 'getNewEntityFormular';
} else {
$method = 'getEntities';
A::insert($params, $request->getQuery(), 0); // query als 1. parameter
}
$entityPart = Inflector::singular($entityPart);
} else {
$method = 'getEntity';
$params = array();
$params[] = $r->shift(); // id
$params[] = count($r->getLeftParts()) > 1 ? $r->getLeftParts() : $r->shift(); // subresource
$params[] = $request->getQuery();
}
} elseif ($request->getType() === self::PUT) {
if ($r->part() === 'grid') {
$entityPart = Inflector::singular($entityPart);
$controller = $this->getEntityController($entityPart);
$method = 'saveSort';
$params = array($r->bvar($controller->getSortField(), array()));
} elseif($request->hasMeta('revision') && $request->getMeta('revision') !== 'default') {
$method = 'saveEntityAsRevision';
A::insert($params, $request->getMeta('revision'), 1);
A::insert($params, (object) $request->getBody(), 2);
} else {
$method = 'saveEntity';
A::insert($params, (object) $request->getBody(), 1); // $formData als parameter 2
}
} elseif ($request->getType() === self::PATCH) {
$method = 'patchEntity';
A::insert($params, (object) $request->getBody(), 1); // $formData als parameter 2
} elseif ($request->getType() === self::DELETE) {
$method = 'deleteEntity'; // das gibt einen "missing argument 1" fehler, wenn id fehlt, aber ka welche httpException ich hier nehmensoll, deshalb bleibt das erstmal so
} elseif ($request->getType() === self::POST) {
$entityPart = Inflector::singular($entityPart); // singular und plural okay
A::insert($params, $request->getBody(), 0); // $formData als parameter 1
if ($request->hasMeta('revision')) {
$method = 'insertEntityRevision';
A::insert($params, $request->getMeta('revision'), 0);
} else {
$method = 'insertEntity';
}
} else {
// das kann glaub ich nicht mehr passieren, weil wir jetzt alle haben: put/pust/delete/get gibts nicht noch head?
throw HTTPException::MethodNotAllowed('Die Methode: '.$request->getType().' ist für diesen Request nicht erlaubt');
}
if (!isset($controller))
$controller = $this->getEntityController($entityPart);
return array($controller, $method, $params);
} | [
"public",
"function",
"routeController",
"(",
"ServiceRequest",
"$",
"request",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"initRequestMatcher",
"(",
"$",
"request",
")",
";",
"$",
"entityPart",
"=",
"$",
"r",
"->",
"qmatchRx",
"(",
"'/^[a-z-0-9]+$/i'",
",",
"0",
")",
";",
"if",
"(",
"mb_strpos",
"(",
"$",
"entityPart",
",",
"'-'",
")",
"!==",
"FALSE",
")",
"{",
"$",
"entityPart",
"=",
"Code",
"::",
"dashToCamelCase",
"(",
"$",
"entityPart",
")",
";",
"}",
"// alle weiteren Parameter an den Controller weitergeben",
"$",
"params",
"=",
"$",
"r",
"->",
"getLeftParts",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"GET",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'EntityPart: '",
".",
"$",
"entityPart",
".",
"' '",
".",
"(",
"$",
"this",
"->",
"isPlural",
"(",
"$",
"entityPart",
")",
"?",
"'ist plural'",
":",
"'ist singular'",
")",
",",
"2",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPlural",
"(",
"$",
"entityPart",
")",
")",
"{",
"if",
"(",
"$",
"r",
"->",
"part",
"(",
")",
"===",
"'form'",
")",
"{",
"$",
"method",
"=",
"'getNewEntityFormular'",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"'getEntities'",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"$",
"request",
"->",
"getQuery",
"(",
")",
",",
"0",
")",
";",
"// query als 1. parameter",
"}",
"$",
"entityPart",
"=",
"Inflector",
"::",
"singular",
"(",
"$",
"entityPart",
")",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"'getEntity'",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"r",
"->",
"shift",
"(",
")",
";",
"// id",
"$",
"params",
"[",
"]",
"=",
"count",
"(",
"$",
"r",
"->",
"getLeftParts",
"(",
")",
")",
">",
"1",
"?",
"$",
"r",
"->",
"getLeftParts",
"(",
")",
":",
"$",
"r",
"->",
"shift",
"(",
")",
";",
"// subresource",
"$",
"params",
"[",
"]",
"=",
"$",
"request",
"->",
"getQuery",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"request",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"PUT",
")",
"{",
"if",
"(",
"$",
"r",
"->",
"part",
"(",
")",
"===",
"'grid'",
")",
"{",
"$",
"entityPart",
"=",
"Inflector",
"::",
"singular",
"(",
"$",
"entityPart",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"getEntityController",
"(",
"$",
"entityPart",
")",
";",
"$",
"method",
"=",
"'saveSort'",
";",
"$",
"params",
"=",
"array",
"(",
"$",
"r",
"->",
"bvar",
"(",
"$",
"controller",
"->",
"getSortField",
"(",
")",
",",
"array",
"(",
")",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"request",
"->",
"hasMeta",
"(",
"'revision'",
")",
"&&",
"$",
"request",
"->",
"getMeta",
"(",
"'revision'",
")",
"!==",
"'default'",
")",
"{",
"$",
"method",
"=",
"'saveEntityAsRevision'",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"$",
"request",
"->",
"getMeta",
"(",
"'revision'",
")",
",",
"1",
")",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"(",
"object",
")",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"'saveEntity'",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"(",
"object",
")",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"1",
")",
";",
"// $formData als parameter 2",
"}",
"}",
"elseif",
"(",
"$",
"request",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"PATCH",
")",
"{",
"$",
"method",
"=",
"'patchEntity'",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"(",
"object",
")",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"1",
")",
";",
"// $formData als parameter 2",
"}",
"elseif",
"(",
"$",
"request",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"DELETE",
")",
"{",
"$",
"method",
"=",
"'deleteEntity'",
";",
"// das gibt einen \"missing argument 1\" fehler, wenn id fehlt, aber ka welche httpException ich hier nehmensoll, deshalb bleibt das erstmal so",
"}",
"elseif",
"(",
"$",
"request",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"POST",
")",
"{",
"$",
"entityPart",
"=",
"Inflector",
"::",
"singular",
"(",
"$",
"entityPart",
")",
";",
"// singular und plural okay",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"0",
")",
";",
"// $formData als parameter 1",
"if",
"(",
"$",
"request",
"->",
"hasMeta",
"(",
"'revision'",
")",
")",
"{",
"$",
"method",
"=",
"'insertEntityRevision'",
";",
"A",
"::",
"insert",
"(",
"$",
"params",
",",
"$",
"request",
"->",
"getMeta",
"(",
"'revision'",
")",
",",
"0",
")",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"'insertEntity'",
";",
"}",
"}",
"else",
"{",
"// das kann glaub ich nicht mehr passieren, weil wir jetzt alle haben: put/pust/delete/get gibts nicht noch head?",
"throw",
"HTTPException",
"::",
"MethodNotAllowed",
"(",
"'Die Methode: '",
".",
"$",
"request",
"->",
"getType",
"(",
")",
".",
"' ist für diesen Request nicht erlaubt')",
";",
"",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"controller",
")",
")",
"$",
"controller",
"=",
"$",
"this",
"->",
"getEntityController",
"(",
"$",
"entityPart",
")",
";",
"return",
"array",
"(",
"$",
"controller",
",",
"$",
"method",
",",
"$",
"params",
")",
";",
"}"
] | Findet den Controller anhand des Requests
GET [/$prefix]/person/1
=>
\Project::getNamespace()\Controllers\PersonController::getEntity(1)
=>
\CoC\Controllers\PersonController::getEntity(1)
GET [/$prefix]/person/1/form
=>
\Project::getNamespace()\Controllers\PersonController::getEntity(1,'form')
GET [/$prefix]/persons/grid?filter1=value1&filter2=value2
=>
\Project::getNamespace()\Controllers\PersonController::getEntities(array('filter1'=>'value1', 'filter2'=>'value2'),'grid') | [
"Findet",
"den",
"Controller",
"anhand",
"des",
"Requests"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/EntityService.php#L85-L163 |
webforge-labs/psc-cms | lib/Psc/CMS/Service/EntityService.php | EntityService.setResponseFromControllerResponse | protected function setResponseFromControllerResponse($controllerResponse, $status = Service::OK, $format = NULL) {
if ($controllerResponse instanceof \Psc\CMS\EntityFormPanel) {
$format = ServiceResponse::HTML;
} elseif ($controllerResponse instanceof \Psc\CMS\Entity) {
$format = ServiceResponse::JSON;
} elseif ($controllerResponse instanceof \Psc\Doctrine\Object) {
$format = ServiceResponse::JSON;
}
parent::setResponseFromControllerResponse($controllerResponse, $status, $format);
} | php | protected function setResponseFromControllerResponse($controllerResponse, $status = Service::OK, $format = NULL) {
if ($controllerResponse instanceof \Psc\CMS\EntityFormPanel) {
$format = ServiceResponse::HTML;
} elseif ($controllerResponse instanceof \Psc\CMS\Entity) {
$format = ServiceResponse::JSON;
} elseif ($controllerResponse instanceof \Psc\Doctrine\Object) {
$format = ServiceResponse::JSON;
}
parent::setResponseFromControllerResponse($controllerResponse, $status, $format);
} | [
"protected",
"function",
"setResponseFromControllerResponse",
"(",
"$",
"controllerResponse",
",",
"$",
"status",
"=",
"Service",
"::",
"OK",
",",
"$",
"format",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"controllerResponse",
"instanceof",
"\\",
"Psc",
"\\",
"CMS",
"\\",
"EntityFormPanel",
")",
"{",
"$",
"format",
"=",
"ServiceResponse",
"::",
"HTML",
";",
"}",
"elseif",
"(",
"$",
"controllerResponse",
"instanceof",
"\\",
"Psc",
"\\",
"CMS",
"\\",
"Entity",
")",
"{",
"$",
"format",
"=",
"ServiceResponse",
"::",
"JSON",
";",
"}",
"elseif",
"(",
"$",
"controllerResponse",
"instanceof",
"\\",
"Psc",
"\\",
"Doctrine",
"\\",
"Object",
")",
"{",
"$",
"format",
"=",
"ServiceResponse",
"::",
"JSON",
";",
"}",
"parent",
"::",
"setResponseFromControllerResponse",
"(",
"$",
"controllerResponse",
",",
"$",
"status",
",",
"$",
"format",
")",
";",
"}"
] | Konvertiert die Responses der Controller in Responses für den RequestHandler | [
"Konvertiert",
"die",
"Responses",
"der",
"Controller",
"in",
"Responses",
"für",
"den",
"RequestHandler"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/EntityService.php#L175-L188 |
yuncms/framework | src/admin/controllers/UserAssignmentController.php | UserAssignmentController.actionIndex | public function actionIndex()
{
$searchModel = new UserAssignmentSearch;
$dataProvider = $searchModel->search(Yii::$app->getRequest()->getQueryParams(), $this->userClassName, $this->usernameField);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'idField' => $this->idField,
'usernameField' => $this->usernameField,
'extraColumns' => $this->extraColumns,
]);
} | php | public function actionIndex()
{
$searchModel = new UserAssignmentSearch;
$dataProvider = $searchModel->search(Yii::$app->getRequest()->getQueryParams(), $this->userClassName, $this->usernameField);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'idField' => $this->idField,
'usernameField' => $this->usernameField,
'extraColumns' => $this->extraColumns,
]);
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"new",
"UserAssignmentSearch",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getQueryParams",
"(",
")",
",",
"$",
"this",
"->",
"userClassName",
",",
"$",
"this",
"->",
"usernameField",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'idField'",
"=>",
"$",
"this",
"->",
"idField",
",",
"'usernameField'",
"=>",
"$",
"this",
"->",
"usernameField",
",",
"'extraColumns'",
"=>",
"$",
"this",
"->",
"extraColumns",
",",
"]",
")",
";",
"}"
] | Lists all Assignment models.
@return mixed | [
"Lists",
"all",
"Assignment",
"models",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/UserAssignmentController.php#L61-L73 |
yuncms/framework | src/admin/controllers/UserAssignmentController.php | UserAssignmentController.actionView | public function actionView($id)
{
$model = $this->findModel($id);
return $this->render('view', [
'model' => $model,
'idField' => $this->idField,
'usernameField' => $this->usernameField,
'fullNameField' => $this->fullNameField,
]);
} | php | public function actionView($id)
{
$model = $this->findModel($id);
return $this->render('view', [
'model' => $model,
'idField' => $this->idField,
'usernameField' => $this->usernameField,
'fullNameField' => $this->fullNameField,
]);
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'view'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'idField'",
"=>",
"$",
"this",
"->",
"idField",
",",
"'usernameField'",
"=>",
"$",
"this",
"->",
"usernameField",
",",
"'fullNameField'",
"=>",
"$",
"this",
"->",
"fullNameField",
",",
"]",
")",
";",
"}"
] | Displays a single Assignment model.
@param integer $id
@return mixed
@throws NotFoundHttpException | [
"Displays",
"a",
"single",
"Assignment",
"model",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/UserAssignmentController.php#L81-L90 |
anime-db/app-bundle | src/Service/PhpFinder.php | PhpFinder.getPath | public function getPath()
{
if (!$this->php_path) {
if (!($this->php_path = $this->finder->find())) {
throw new \RuntimeException(
'The php executable could not be found, add it to your PATH environment variable and try again'
);
}
$this->php_path = escapeshellarg($this->php_path);
}
return $this->php_path;
} | php | public function getPath()
{
if (!$this->php_path) {
if (!($this->php_path = $this->finder->find())) {
throw new \RuntimeException(
'The php executable could not be found, add it to your PATH environment variable and try again'
);
}
$this->php_path = escapeshellarg($this->php_path);
}
return $this->php_path;
} | [
"public",
"function",
"getPath",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"php_path",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"php_path",
"=",
"$",
"this",
"->",
"finder",
"->",
"find",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The php executable could not be found, add it to your PATH environment variable and try again'",
")",
";",
"}",
"$",
"this",
"->",
"php_path",
"=",
"escapeshellarg",
"(",
"$",
"this",
"->",
"php_path",
")",
";",
"}",
"return",
"$",
"this",
"->",
"php_path",
";",
"}"
] | @throws \RuntimeException
@return string | [
"@throws",
"\\",
"RuntimeException"
] | train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/PhpFinder.php#L38-L50 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.setKey | public function setKey($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->key !== $v) {
$this->key = $v;
$this->modifiedColumns[] = SystemSettingsPeer::KEY;
}
return $this;
} | php | public function setKey($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->key !== $v) {
$this->key = $v;
$this->modifiedColumns[] = SystemSettingsPeer::KEY;
}
return $this;
} | [
"public",
"function",
"setKey",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"key",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"SystemSettingsPeer",
"::",
"KEY",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [key] column.
@param string $v new value
@return SystemSettings The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"key",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L137-L150 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.setValue | public function setValue($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->value !== $v) {
$this->value = $v;
$this->modifiedColumns[] = SystemSettingsPeer::VALUE;
}
return $this;
} | php | public function setValue($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->value !== $v) {
$this->value = $v;
$this->modifiedColumns[] = SystemSettingsPeer::VALUE;
}
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"value",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"SystemSettingsPeer",
"::",
"VALUE",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [value] column.
@param string $v new value
@return SystemSettings The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"value",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L158-L171 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.doInsert | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = SystemSettingsPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . SystemSettingsPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(SystemSettingsPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(SystemSettingsPeer::KEY)) {
$modifiedColumns[':p' . $index++] = '`key`';
}
if ($this->isColumnModified(SystemSettingsPeer::VALUE)) {
$modifiedColumns[':p' . $index++] = '`value`';
}
$sql = sprintf(
'INSERT INTO `system_settings` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`key`':
$stmt->bindValue($identifier, $this->key, PDO::PARAM_STR);
break;
case '`value`':
$stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | php | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = SystemSettingsPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . SystemSettingsPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(SystemSettingsPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(SystemSettingsPeer::KEY)) {
$modifiedColumns[':p' . $index++] = '`key`';
}
if ($this->isColumnModified(SystemSettingsPeer::VALUE)) {
$modifiedColumns[':p' . $index++] = '`value`';
}
$sql = sprintf(
'INSERT INTO `system_settings` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`key`':
$stmt->bindValue($identifier, $this->key, PDO::PARAM_STR);
break;
case '`value`':
$stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"SystemSettingsPeer",
"::",
"ID",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"SystemSettingsPeer",
"::",
"ID",
".",
"')'",
")",
";",
"}",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"KEY",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`key`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"VALUE",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`value`'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO `system_settings` (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'`id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`key`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"key",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'`value`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"value",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"pk",
"=",
"$",
"con",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unable to get autoincrement id.'",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setId",
"(",
"$",
"pk",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
] | Insert the row in the database.
@param PropelPDO $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L418-L474 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.doValidate | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = SystemSettingsPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | php | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = SystemSettingsPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"protected",
"function",
"doValidate",
"(",
"$",
"columns",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInValidation",
")",
"{",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"true",
";",
"$",
"retval",
"=",
"null",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"$",
"retval",
"=",
"SystemSettingsPeer",
"::",
"doValidate",
"(",
"$",
"this",
",",
"$",
"columns",
")",
")",
"!==",
"true",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"retval",
")",
";",
"}",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
] | This function performs the validation work for complex object models.
In addition to checking the current object, all related objects will
also be validated. If all pass then <code>true</code> is returned; otherwise
an aggregated array of ValidationFailed objects will be returned.
@param array $columns Array of column names to validate.
@return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise. | [
"This",
"function",
"performs",
"the",
"validation",
"work",
"for",
"complex",
"object",
"models",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L543-L562 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.getByPosition | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getKey();
break;
case 2:
return $this->getValue();
break;
default:
return null;
break;
} // switch()
} | php | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getKey();
break;
case 2:
return $this->getValue();
break;
default:
return null;
break;
} // switch()
} | [
"public",
"function",
"getByPosition",
"(",
"$",
"pos",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"return",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"return",
"$",
"this",
"->",
"getKey",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"return",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"// switch()",
"}"
] | Retrieves a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@return mixed Value of field at $pos | [
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L589-L605 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.toArray | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
if (isset($alreadyDumpedObjects['SystemSettings'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['SystemSettings'][$this->getPrimaryKey()] = true;
$keys = SystemSettingsPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getKey(),
$keys[2] => $this->getValue(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
return $result;
} | php | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
if (isset($alreadyDumpedObjects['SystemSettings'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['SystemSettings'][$this->getPrimaryKey()] = true;
$keys = SystemSettingsPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getKey(),
$keys[2] => $this->getValue(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'SystemSettings'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'SystemSettings'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"SystemSettingsPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getKey",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L621-L640 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setKey($value);
break;
case 2:
$this->setValue($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setKey($value);
break;
case 2:
$this->setValue($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setKey",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
] | Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L668-L681 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.fromArray | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = SystemSettingsPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setKey($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
} | php | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = SystemSettingsPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setKey($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"SystemSettingsPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setKey",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setValue",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"}"
] | Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
The default key type is the column's BasePeer::TYPE_PHPNAME
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L700-L707 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(SystemSettingsPeer::DATABASE_NAME);
if ($this->isColumnModified(SystemSettingsPeer::ID)) $criteria->add(SystemSettingsPeer::ID, $this->id);
if ($this->isColumnModified(SystemSettingsPeer::KEY)) $criteria->add(SystemSettingsPeer::KEY, $this->key);
if ($this->isColumnModified(SystemSettingsPeer::VALUE)) $criteria->add(SystemSettingsPeer::VALUE, $this->value);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(SystemSettingsPeer::DATABASE_NAME);
if ($this->isColumnModified(SystemSettingsPeer::ID)) $criteria->add(SystemSettingsPeer::ID, $this->id);
if ($this->isColumnModified(SystemSettingsPeer::KEY)) $criteria->add(SystemSettingsPeer::KEY, $this->key);
if ($this->isColumnModified(SystemSettingsPeer::VALUE)) $criteria->add(SystemSettingsPeer::VALUE, $this->value);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"SystemSettingsPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"SystemSettingsPeer",
"::",
"ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"KEY",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"SystemSettingsPeer",
"::",
"KEY",
",",
"$",
"this",
"->",
"key",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"SystemSettingsPeer",
"::",
"VALUE",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"SystemSettingsPeer",
"::",
"VALUE",
",",
"$",
"this",
"->",
"value",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] | Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L714-L723 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setKey($this->getKey());
$copyObj->setValue($this->getValue());
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setKey($this->getKey());
$copyObj->setValue($this->getValue());
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setKey",
"(",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setValue",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"copyObj",
"->",
"setId",
"(",
"NULL",
")",
";",
"// this is a auto-increment column, so set to default value",
"}",
"}"
] | Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of SystemSettings (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L782-L790 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php | BaseSystemSettings.clear | public function clear()
{
$this->id = null;
$this->key = null;
$this->value = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | php | public function clear()
{
$this->id = null;
$this->key = null;
$this->value = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"$",
"this",
"->",
"key",
"=",
"null",
";",
"$",
"this",
"->",
"value",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
] | Clears the current object and sets all attributes to their default values | [
"Clears",
"the",
"current",
"object",
"and",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettings.php#L835-L847 |
digitalkaoz/versioneye-php | src/Api/Github.php | Github.repos | public function repos($language = null, $private = null, $organization = null, $type = null, $imported = null)
{
return $this->request(sprintf('github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b',
$language, $private, $organization, $type, 1, $imported
));
} | php | public function repos($language = null, $private = null, $organization = null, $type = null, $imported = null)
{
return $this->request(sprintf('github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b',
$language, $private, $organization, $type, 1, $imported
));
} | [
"public",
"function",
"repos",
"(",
"$",
"language",
"=",
"null",
",",
"$",
"private",
"=",
"null",
",",
"$",
"organization",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"imported",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"sprintf",
"(",
"'github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b'",
",",
"$",
"language",
",",
"$",
"private",
",",
"$",
"organization",
",",
"$",
"type",
",",
"1",
",",
"$",
"imported",
")",
")",
";",
"}"
] | lists your's github repos.
@param string $language
@param bool $private
@param string $organization
@param string $type
@param bool $imported
@return array | [
"lists",
"your",
"s",
"github",
"repos",
"."
] | train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Api/Github.php#L25-L30 |
digitalkaoz/versioneye-php | src/Api/Github.php | Github.import | public function import($repository, $branch = null, $file = null)
{
return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST');
} | php | public function import($repository, $branch = null, $file = null)
{
return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST');
} | [
"public",
"function",
"import",
"(",
"$",
"repository",
",",
"$",
"branch",
"=",
"null",
",",
"$",
"file",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"sprintf",
"(",
"'github/%s?branch=%s&file=%s'",
",",
"$",
"this",
"->",
"transform",
"(",
"$",
"repository",
")",
",",
"$",
"branch",
",",
"$",
"file",
")",
",",
"'POST'",
")",
";",
"}"
] | imports project file from github.
@param string $repository
@param string $branch
@param string $file
@return array | [
"imports",
"project",
"file",
"from",
"github",
"."
] | train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Api/Github.php#L63-L66 |
yuncms/framework | src/oauth2/grant/types/QRCode.php | QRCode.getAccessToken | public function getAccessToken()
{
if (is_null($this->_accessToken)) {
if (empty($this->access_token)) {
$this->errorServer(Yii::t('yuncms', 'The request is missing "access_token" parameter'));
}
if (!$this->_accessToken = OAuth2AccessToken::findOne(['access_token' => $this->access_token])) {
$this->errorServer(Yii::t('yuncms', 'The Access Token is invalid'));
}
}
return $this->_accessToken;
} | php | public function getAccessToken()
{
if (is_null($this->_accessToken)) {
if (empty($this->access_token)) {
$this->errorServer(Yii::t('yuncms', 'The request is missing "access_token" parameter'));
}
if (!$this->_accessToken = OAuth2AccessToken::findOne(['access_token' => $this->access_token])) {
$this->errorServer(Yii::t('yuncms', 'The Access Token is invalid'));
}
}
return $this->_accessToken;
} | [
"public",
"function",
"getAccessToken",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_accessToken",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"access_token",
")",
")",
"{",
"$",
"this",
"->",
"errorServer",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'The request is missing \"access_token\" parameter'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_accessToken",
"=",
"OAuth2AccessToken",
"::",
"findOne",
"(",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"access_token",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errorServer",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'The Access Token is invalid'",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_accessToken",
";",
"}"
] | 获取 AccessToken 实例
@return OAuth2AccessToken
@throws Exception | [
"获取",
"AccessToken",
"实例"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/oauth2/grant/types/QRCode.php#L124-L135 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.getLastItemInFQNBlock | public function getLastItemInFQNBlock($fqn, $delimiter)
{
if (false === $fqnBlock = explode($delimiter, $fqn)) {
return $fqnBlock;
}
return (string) $fqnBlock[count($fqnBlock) - 1];
} | php | public function getLastItemInFQNBlock($fqn, $delimiter)
{
if (false === $fqnBlock = explode($delimiter, $fqn)) {
return $fqnBlock;
}
return (string) $fqnBlock[count($fqnBlock) - 1];
} | [
"public",
"function",
"getLastItemInFQNBlock",
"(",
"$",
"fqn",
",",
"$",
"delimiter",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"fqnBlock",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"fqn",
")",
")",
"{",
"return",
"$",
"fqnBlock",
";",
"}",
"return",
"(",
"string",
")",
"$",
"fqnBlock",
"[",
"count",
"(",
"$",
"fqnBlock",
")",
"-",
"1",
"]",
";",
"}"
] | @param string $fqn
@param string $delimiter
@return string | [
"@param",
"string",
"$fqn",
"@param",
"string",
"$delimiter"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L77-L84 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.getClassFromUse | public function getClassFromUse($coverClassName, $usedClasses)
{
if (false === is_array($usedClasses)) {
return $coverClassName;
}
foreach ($usedClasses as $use) {
$this->getClassNameFromClassFQN($use);
if ($coverClassName === $this->getClassNameFromClassFQN($use)) {
return $use;
}
}
return $coverClassName;
} | php | public function getClassFromUse($coverClassName, $usedClasses)
{
if (false === is_array($usedClasses)) {
return $coverClassName;
}
foreach ($usedClasses as $use) {
$this->getClassNameFromClassFQN($use);
if ($coverClassName === $this->getClassNameFromClassFQN($use)) {
return $use;
}
}
return $coverClassName;
} | [
"public",
"function",
"getClassFromUse",
"(",
"$",
"coverClassName",
",",
"$",
"usedClasses",
")",
"{",
"if",
"(",
"false",
"===",
"is_array",
"(",
"$",
"usedClasses",
")",
")",
"{",
"return",
"$",
"coverClassName",
";",
"}",
"foreach",
"(",
"$",
"usedClasses",
"as",
"$",
"use",
")",
"{",
"$",
"this",
"->",
"getClassNameFromClassFQN",
"(",
"$",
"use",
")",
";",
"if",
"(",
"$",
"coverClassName",
"===",
"$",
"this",
"->",
"getClassNameFromClassFQN",
"(",
"$",
"use",
")",
")",
"{",
"return",
"$",
"use",
";",
"}",
"}",
"return",
"$",
"coverClassName",
";",
"}"
] | check for className in use statements, return className on missing use statement
@param string $coverClassName
@param array|null $usedClasses
@return string | [
"check",
"for",
"className",
"in",
"use",
"statements",
"return",
"className",
"on",
"missing",
"use",
"statement"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L94-L108 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.getUsedClassesInClass | public function getUsedClassesInClass($classFile)
{
$useResult = array();
$content = $this->getFileContent($classFile);
if (preg_match_all('/(use\s+)(.*)(;)/', $content, $useResult) && 4 === count($useResult)) {
// @todo: use keyName based result check instead of index!
return ($useResult[2]);
}
return null;
} | php | public function getUsedClassesInClass($classFile)
{
$useResult = array();
$content = $this->getFileContent($classFile);
if (preg_match_all('/(use\s+)(.*)(;)/', $content, $useResult) && 4 === count($useResult)) {
// @todo: use keyName based result check instead of index!
return ($useResult[2]);
}
return null;
} | [
"public",
"function",
"getUsedClassesInClass",
"(",
"$",
"classFile",
")",
"{",
"$",
"useResult",
"=",
"array",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getFileContent",
"(",
"$",
"classFile",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/(use\\s+)(.*)(;)/'",
",",
"$",
"content",
",",
"$",
"useResult",
")",
"&&",
"4",
"===",
"count",
"(",
"$",
"useResult",
")",
")",
"{",
"// @todo: use keyName based result check instead of index!",
"return",
"(",
"$",
"useResult",
"[",
"2",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | return all in file use statement defined classes
@param string $classFile absolute path of readable class file
@return array | [
"return",
"all",
"in",
"file",
"use",
"statement",
"defined",
"classes"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L117-L127 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.checkPath | public function checkPath($path)
{
$path = realpath($path);
return ($path !== false && is_dir($path)) ? $path : false;
} | php | public function checkPath($path)
{
$path = realpath($path);
return ($path !== false && is_dir($path)) ? $path : false;
} | [
"public",
"function",
"checkPath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"return",
"(",
"$",
"path",
"!==",
"false",
"&&",
"is_dir",
"(",
"$",
"path",
")",
")",
"?",
"$",
"path",
":",
"false",
";",
"}"
] | @param string $path
@return string|false | [
"@param",
"string",
"$path"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L150-L155 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.getAnnotationByKey | public function getAnnotationByKey($docBlock, $key)
{
/** @var array $classAnnotations */
$classAnnotations = $this->parseCoverAnnotationDocBlock($docBlock);
if (false === array_key_exists($key, $classAnnotations)) {
return array();
}
return $classAnnotations[$key];
} | php | public function getAnnotationByKey($docBlock, $key)
{
/** @var array $classAnnotations */
$classAnnotations = $this->parseCoverAnnotationDocBlock($docBlock);
if (false === array_key_exists($key, $classAnnotations)) {
return array();
}
return $classAnnotations[$key];
} | [
"public",
"function",
"getAnnotationByKey",
"(",
"$",
"docBlock",
",",
"$",
"key",
")",
"{",
"/** @var array $classAnnotations */",
"$",
"classAnnotations",
"=",
"$",
"this",
"->",
"parseCoverAnnotationDocBlock",
"(",
"$",
"docBlock",
")",
";",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"classAnnotations",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"classAnnotations",
"[",
"$",
"key",
"]",
";",
"}"
] | fetch annotation key value(s) as array from corresponding class docBlock directly
@param string $docBlock
@param string $key
@return array | [
"fetch",
"annotation",
"key",
"value",
"(",
"s",
")",
"as",
"array",
"from",
"corresponding",
"class",
"docBlock",
"directly"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L209-L218 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.getAttributeByKey | public function getAttributeByKey($key, array $classData)
{
if (false === array_key_exists($key, $classData)) {
return '';
}
return (string) $classData[$key];
} | php | public function getAttributeByKey($key, array $classData)
{
if (false === array_key_exists($key, $classData)) {
return '';
}
return (string) $classData[$key];
} | [
"public",
"function",
"getAttributeByKey",
"(",
"$",
"key",
",",
"array",
"$",
"classData",
")",
"{",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"classData",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"(",
"string",
")",
"$",
"classData",
"[",
"$",
"key",
"]",
";",
"}"
] | @param string $key
@param array $classData
@return string | [
"@param",
"string",
"$key",
"@param",
"array",
"$classData"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L226-L233 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Common/CoverFishHelper.php | CoverFishHelper.parseCoverAnnotationDocBlock | public function parseCoverAnnotationDocBlock($docBlock)
{
$annotations = array('covers' => array(), 'uses' => array());
$docBlock = substr($docBlock, 3, -2);
if (preg_match_all('/@(?P<name>[A-Za-z_-]+)(?:[ \t]+(?P<value>.*?))?[ \t]*\r?$/m', $docBlock, $matches)) {
$numMatches = count($matches[0]);
for ($i = 0; $i < $numMatches; ++$i) {
$annotations[$matches['name'][$i]][] = $matches['value'][$i];
}
}
array_walk_recursive(
$annotations,
function(&$element) {
if (substr($element, 0, 1) === '\\') {
$element = substr($element, 1);
}
}
);
return $annotations;
} | php | public function parseCoverAnnotationDocBlock($docBlock)
{
$annotations = array('covers' => array(), 'uses' => array());
$docBlock = substr($docBlock, 3, -2);
if (preg_match_all('/@(?P<name>[A-Za-z_-]+)(?:[ \t]+(?P<value>.*?))?[ \t]*\r?$/m', $docBlock, $matches)) {
$numMatches = count($matches[0]);
for ($i = 0; $i < $numMatches; ++$i) {
$annotations[$matches['name'][$i]][] = $matches['value'][$i];
}
}
array_walk_recursive(
$annotations,
function(&$element) {
if (substr($element, 0, 1) === '\\') {
$element = substr($element, 1);
}
}
);
return $annotations;
} | [
"public",
"function",
"parseCoverAnnotationDocBlock",
"(",
"$",
"docBlock",
")",
"{",
"$",
"annotations",
"=",
"array",
"(",
"'covers'",
"=>",
"array",
"(",
")",
",",
"'uses'",
"=>",
"array",
"(",
")",
")",
";",
"$",
"docBlock",
"=",
"substr",
"(",
"$",
"docBlock",
",",
"3",
",",
"-",
"2",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/@(?P<name>[A-Za-z_-]+)(?:[ \\t]+(?P<value>.*?))?[ \\t]*\\r?$/m'",
",",
"$",
"docBlock",
",",
"$",
"matches",
")",
")",
"{",
"$",
"numMatches",
"=",
"count",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numMatches",
";",
"++",
"$",
"i",
")",
"{",
"$",
"annotations",
"[",
"$",
"matches",
"[",
"'name'",
"]",
"[",
"$",
"i",
"]",
"]",
"[",
"]",
"=",
"$",
"matches",
"[",
"'value'",
"]",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"array_walk_recursive",
"(",
"$",
"annotations",
",",
"function",
"(",
"&",
"$",
"element",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"element",
",",
"0",
",",
"1",
")",
"===",
"'\\\\'",
")",
"{",
"$",
"element",
"=",
"substr",
"(",
"$",
"element",
",",
"1",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"annotations",
";",
"}"
] | @param string $docBlock
@return array | [
"@param",
"string",
"$docBlock"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L250-L269 |
factorio-item-browser/export-data | src/Registry/ContentRegistry.php | ContentRegistry.set | public function set(string $hash, string $content): void
{
$this->saveContent($hash, $content);
} | php | public function set(string $hash, string $content): void
{
$this->saveContent($hash, $content);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"hash",
",",
"string",
"$",
"content",
")",
":",
"void",
"{",
"$",
"this",
"->",
"saveContent",
"(",
"$",
"hash",
",",
"$",
"content",
")",
";",
"}"
] | Sets content into the registry.
@param string $hash
@param string $content | [
"Sets",
"content",
"into",
"the",
"registry",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ContentRegistry.php#L20-L23 |
gries/rcon | src/MessengerFactory.php | MessengerFactory.create | public static function create($host, $port, $password)
{
$connection = ConnectionFactory::create($host, $port, $password);
return new Messenger($connection);
} | php | public static function create($host, $port, $password)
{
$connection = ConnectionFactory::create($host, $port, $password);
return new Messenger($connection);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"password",
")",
"{",
"$",
"connection",
"=",
"ConnectionFactory",
"::",
"create",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"password",
")",
";",
"return",
"new",
"Messenger",
"(",
"$",
"connection",
")",
";",
"}"
] | Create a new RconMessenger
@param $host
@param $port
@param $password
@return \gries\Rcon\Messenger | [
"Create",
"a",
"new",
"RconMessenger"
] | train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/MessengerFactory.php#L24-L29 |
slashworks/control-bundle | src/Slashworks/BackendBundle/DataFixtures/ORM/LoadUserData.php | LoadUserData.load | public function load(ObjectManager $manager)
{
$user = new User();
$user->setUsername("someuser");
$user->setSalt(md5(uniqid()));
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
$user->setPassword($encoder->encodePassword('blue', $user->getSalt()));
$user->setEmail("[email protected]");
$manager->persist($user);
$manager->flush();
} | php | public function load(ObjectManager $manager)
{
$user = new User();
$user->setUsername("someuser");
$user->setSalt(md5(uniqid()));
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
$user->setPassword($encoder->encodePassword('blue', $user->getSalt()));
$user->setEmail("[email protected]");
$manager->persist($user);
$manager->flush();
} | [
"public",
"function",
"load",
"(",
"ObjectManager",
"$",
"manager",
")",
"{",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"$",
"user",
"->",
"setUsername",
"(",
"\"someuser\"",
")",
";",
"$",
"user",
"->",
"setSalt",
"(",
"md5",
"(",
"uniqid",
"(",
")",
")",
")",
";",
"$",
"encoder",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'security.encoder_factory'",
")",
"->",
"getEncoder",
"(",
"$",
"user",
")",
";",
"$",
"user",
"->",
"setPassword",
"(",
"$",
"encoder",
"->",
"encodePassword",
"(",
"'blue'",
",",
"$",
"user",
"->",
"getSalt",
"(",
")",
")",
")",
";",
"$",
"user",
"->",
"setEmail",
"(",
"\"[email protected]\"",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"user",
")",
";",
"$",
"manager",
"->",
"flush",
"(",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/DataFixtures/ORM/LoadUserData.php#L33-L46 |
Nozemi/SlickBoard-Library | lib/SBLib/Utilities/Config.php | Config.get | public function get($name, $default = null, $file = null) {
$configVal = null;
if(is_array($this->config)) {
if($file === null) {
if(count(array_column($this->config, $name)) > 0) {
$configVal = array_column($this->config, $name)[0];
} else {
$configVal = array_column($this->config, $name);
}
} else {
if(count(array_column($this->config->$file, $name)) > 0) {
$configVal = array_column($this->config->$file, $name)[0];
} else {
$configVal = array_column($this->config->$file, $name);
}
}
}
if(empty($configVal)) {
return $default;
}
return $configVal;
} | php | public function get($name, $default = null, $file = null) {
$configVal = null;
if(is_array($this->config)) {
if($file === null) {
if(count(array_column($this->config, $name)) > 0) {
$configVal = array_column($this->config, $name)[0];
} else {
$configVal = array_column($this->config, $name);
}
} else {
if(count(array_column($this->config->$file, $name)) > 0) {
$configVal = array_column($this->config->$file, $name)[0];
} else {
$configVal = array_column($this->config->$file, $name);
}
}
}
if(empty($configVal)) {
return $default;
}
return $configVal;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"file",
"=",
"null",
")",
"{",
"$",
"configVal",
"=",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"config",
")",
")",
"{",
"if",
"(",
"$",
"file",
"===",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"array_column",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"name",
")",
")",
">",
"0",
")",
"{",
"$",
"configVal",
"=",
"array_column",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"name",
")",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"configVal",
"=",
"array_column",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"name",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"array_column",
"(",
"$",
"this",
"->",
"config",
"->",
"$",
"file",
",",
"$",
"name",
")",
")",
">",
"0",
")",
"{",
"$",
"configVal",
"=",
"array_column",
"(",
"$",
"this",
"->",
"config",
"->",
"$",
"file",
",",
"$",
"name",
")",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"configVal",
"=",
"array_column",
"(",
"$",
"this",
"->",
"config",
"->",
"$",
"file",
",",
"$",
"name",
")",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"configVal",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"configVal",
";",
"}"
] | Gets a config value from the config array.
@param string $name
@param string $file
@param mixed $default
@return mixed | [
"Gets",
"a",
"config",
"value",
"from",
"the",
"config",
"array",
"."
] | train | https://github.com/Nozemi/SlickBoard-Library/blob/c9f0a26a30f8127c997f75d7232eac170972418d/lib/SBLib/Utilities/Config.php#L83-L107 |
matks/MarkdownBlogBundle | Blog/Register/YamlLibraryRegister.php | YamlLibraryRegister.validateRegisterFilepath | private function validateRegisterFilepath($registerFilepath)
{
if (false === file_exists($registerFilepath)) {
throw new \InvalidArgumentException("File $registerFilepath does not exist");
}
$yamlPattern = '#' . '(.*)\.yml$' . '#';
$isAYamlFile = preg_match($yamlPattern, $registerFilepath);
if (false === $isAYamlFile) {
throw new \InvalidArgumentException("File $registerFilepath is not a YAML file");
}
} | php | private function validateRegisterFilepath($registerFilepath)
{
if (false === file_exists($registerFilepath)) {
throw new \InvalidArgumentException("File $registerFilepath does not exist");
}
$yamlPattern = '#' . '(.*)\.yml$' . '#';
$isAYamlFile = preg_match($yamlPattern, $registerFilepath);
if (false === $isAYamlFile) {
throw new \InvalidArgumentException("File $registerFilepath is not a YAML file");
}
} | [
"private",
"function",
"validateRegisterFilepath",
"(",
"$",
"registerFilepath",
")",
"{",
"if",
"(",
"false",
"===",
"file_exists",
"(",
"$",
"registerFilepath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"File $registerFilepath does not exist\"",
")",
";",
"}",
"$",
"yamlPattern",
"=",
"'#'",
".",
"'(.*)\\.yml$'",
".",
"'#'",
";",
"$",
"isAYamlFile",
"=",
"preg_match",
"(",
"$",
"yamlPattern",
",",
"$",
"registerFilepath",
")",
";",
"if",
"(",
"false",
"===",
"$",
"isAYamlFile",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"File $registerFilepath is not a YAML file\"",
")",
";",
"}",
"}"
] | @param string $registerFilepath
@throws \InvalidArgumentException | [
"@param",
"string",
"$registerFilepath"
] | train | https://github.com/matks/MarkdownBlogBundle/blob/b3438f143ece5e926b891d8f481dba35948b05fb/Blog/Register/YamlLibraryRegister.php#L60-L72 |
kattsoftware/phassets | src/Phassets/Filters/CssCompactFilter.php | CssCompactFilter.filter | public function filter(Asset $asset)
{
if ($asset->getOutputExtension() !== 'css') {
throw new PhassetsInternalException('Only .css files can be filtered by ' . __CLASS__);
}
try {
$cssParser = new Parser($asset->getContents());
$result = $cssParser->parse()->render(OutputFormat::createCompact());
} catch (UnexpectedTokenException $e) {
throw new PhassetsInternalException(
__CLASS__ . ': UnexpectedTokenException caught',
$e->getCode(),
$e
);
} catch (SourceException $e) {
throw new PhassetsInternalException(
__CLASS__ . ': SourceException caught',
$e->getCode(),
$e
);
}
$asset->setContents($result);
} | php | public function filter(Asset $asset)
{
if ($asset->getOutputExtension() !== 'css') {
throw new PhassetsInternalException('Only .css files can be filtered by ' . __CLASS__);
}
try {
$cssParser = new Parser($asset->getContents());
$result = $cssParser->parse()->render(OutputFormat::createCompact());
} catch (UnexpectedTokenException $e) {
throw new PhassetsInternalException(
__CLASS__ . ': UnexpectedTokenException caught',
$e->getCode(),
$e
);
} catch (SourceException $e) {
throw new PhassetsInternalException(
__CLASS__ . ': SourceException caught',
$e->getCode(),
$e
);
}
$asset->setContents($result);
} | [
"public",
"function",
"filter",
"(",
"Asset",
"$",
"asset",
")",
"{",
"if",
"(",
"$",
"asset",
"->",
"getOutputExtension",
"(",
")",
"!==",
"'css'",
")",
"{",
"throw",
"new",
"PhassetsInternalException",
"(",
"'Only .css files can be filtered by '",
".",
"__CLASS__",
")",
";",
"}",
"try",
"{",
"$",
"cssParser",
"=",
"new",
"Parser",
"(",
"$",
"asset",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"cssParser",
"->",
"parse",
"(",
")",
"->",
"render",
"(",
"OutputFormat",
"::",
"createCompact",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnexpectedTokenException",
"$",
"e",
")",
"{",
"throw",
"new",
"PhassetsInternalException",
"(",
"__CLASS__",
".",
"': UnexpectedTokenException caught'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"SourceException",
"$",
"e",
")",
"{",
"throw",
"new",
"PhassetsInternalException",
"(",
"__CLASS__",
".",
"': SourceException caught'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"$",
"asset",
"->",
"setContents",
"(",
"$",
"result",
")",
";",
"}"
] | Process the Asset received and using Asset::setContents(), update
the contents accordingly. If it fails, will throw PhassetsInternalException
@param Asset $asset Asset instance which will be updated via setContents()
@throws PhassetsInternalException in case of failure | [
"Process",
"the",
"Asset",
"received",
"and",
"using",
"Asset",
"::",
"setContents",
"()",
"update",
"the",
"contents",
"accordingly",
".",
"If",
"it",
"fails",
"will",
"throw",
"PhassetsInternalException"
] | train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Filters/CssCompactFilter.php#L39-L64 |
digitalkaoz/versioneye-php | src/Http/Pager.php | Pager.valid | public function valid()
{
if (!isset($this->result[$this->offset]) && $this->offset < $this->max) {
++$this->current;
$url = preg_replace('/page=[0-9]+/', 'page=' . $this->current, $this->url);
$result = $this->client->request($this->method, $url, $this->params);
$this->result = array_merge($this->result, $result[$this->key]);
return true;
}
return $this->offset < $this->max;
} | php | public function valid()
{
if (!isset($this->result[$this->offset]) && $this->offset < $this->max) {
++$this->current;
$url = preg_replace('/page=[0-9]+/', 'page=' . $this->current, $this->url);
$result = $this->client->request($this->method, $url, $this->params);
$this->result = array_merge($this->result, $result[$this->key]);
return true;
}
return $this->offset < $this->max;
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"result",
"[",
"$",
"this",
"->",
"offset",
"]",
")",
"&&",
"$",
"this",
"->",
"offset",
"<",
"$",
"this",
"->",
"max",
")",
"{",
"++",
"$",
"this",
"->",
"current",
";",
"$",
"url",
"=",
"preg_replace",
"(",
"'/page=[0-9]+/'",
",",
"'page='",
".",
"$",
"this",
"->",
"current",
",",
"$",
"this",
"->",
"url",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"this",
"->",
"method",
",",
"$",
"url",
",",
"$",
"this",
"->",
"params",
")",
";",
"$",
"this",
"->",
"result",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"result",
",",
"$",
"result",
"[",
"$",
"this",
"->",
"key",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"offset",
"<",
"$",
"this",
"->",
"max",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Http/Pager.php#L74-L87 |
dreamfactorysoftware/df-file | src/ServiceProvider.php | ServiceProvider.boot | public function boot()
{
// add our df config
$configPath = __DIR__ . '/../config/config.php';
if (function_exists('config_path')) {
$publishPath = config_path('df.php');
} else {
$publishPath = base_path('config/df.php');
}
$this->publishes([$configPath => $publishPath], 'config');
// add routes
/** @noinspection PhpUndefinedMethodInspection */
if (!$this->app->routesAreCached()) {
include __DIR__ . '/../routes/routes.php';
}
// add migrations, https://laravel.com/docs/5.4/packages#resources
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
} | php | public function boot()
{
// add our df config
$configPath = __DIR__ . '/../config/config.php';
if (function_exists('config_path')) {
$publishPath = config_path('df.php');
} else {
$publishPath = base_path('config/df.php');
}
$this->publishes([$configPath => $publishPath], 'config');
// add routes
/** @noinspection PhpUndefinedMethodInspection */
if (!$this->app->routesAreCached()) {
include __DIR__ . '/../routes/routes.php';
}
// add migrations, https://laravel.com/docs/5.4/packages#resources
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"// add our df config",
"$",
"configPath",
"=",
"__DIR__",
".",
"'/../config/config.php'",
";",
"if",
"(",
"function_exists",
"(",
"'config_path'",
")",
")",
"{",
"$",
"publishPath",
"=",
"config_path",
"(",
"'df.php'",
")",
";",
"}",
"else",
"{",
"$",
"publishPath",
"=",
"base_path",
"(",
"'config/df.php'",
")",
";",
"}",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
"configPath",
"=>",
"$",
"publishPath",
"]",
",",
"'config'",
")",
";",
"// add routes",
"/** @noinspection PhpUndefinedMethodInspection */",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"routesAreCached",
"(",
")",
")",
"{",
"include",
"__DIR__",
".",
"'/../routes/routes.php'",
";",
"}",
"// add migrations, https://laravel.com/docs/5.4/packages#resources",
"$",
"this",
"->",
"loadMigrationsFrom",
"(",
"__DIR__",
".",
"'/../database/migrations'",
")",
";",
"}"
] | Bootstrap the application events. | [
"Bootstrap",
"the",
"application",
"events",
"."
] | train | https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/ServiceProvider.php#L23-L42 |
dreamfactorysoftware/df-file | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
// merge in df config, https://laravel.com/docs/5.4/packages#resources
$configPath = __DIR__ . '/../config/config.php';
$this->mergeConfigFrom($configPath, 'df');
// Add our service types.
$this->app->resolving('df.service', function (ServiceManager $df){
$df->addType(
new ServiceType([
'name' => 'local_file',
'label' => 'Local File Storage',
'description' => 'File service supporting the local file system.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => LocalFileConfig::class,
'factory' => function ($config){
return new LocalFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'ftp_file',
'label' => 'FTP File Storage',
'description' => 'File service supporting the FTP protocol.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => FTPFileConfig::class,
'factory' => function ($config){
return new FTPFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'sftp_file',
'label' => 'SFTP File Storage',
'description' => 'File service supporting the SFTP protocol.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => SFTPFileConfig::class,
'factory' => function ($config){
return new SFTPFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'webdav_file',
'label' => 'WebDAV File Storage',
'description' => 'File service supporting WebDAV.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => WebDAVFileConfig::class,
'factory' => function ($config){
return new WebDAVFileService($config);
},
])
);
});
} | php | public function register()
{
// merge in df config, https://laravel.com/docs/5.4/packages#resources
$configPath = __DIR__ . '/../config/config.php';
$this->mergeConfigFrom($configPath, 'df');
// Add our service types.
$this->app->resolving('df.service', function (ServiceManager $df){
$df->addType(
new ServiceType([
'name' => 'local_file',
'label' => 'Local File Storage',
'description' => 'File service supporting the local file system.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => LocalFileConfig::class,
'factory' => function ($config){
return new LocalFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'ftp_file',
'label' => 'FTP File Storage',
'description' => 'File service supporting the FTP protocol.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => FTPFileConfig::class,
'factory' => function ($config){
return new FTPFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'sftp_file',
'label' => 'SFTP File Storage',
'description' => 'File service supporting the SFTP protocol.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => SFTPFileConfig::class,
'factory' => function ($config){
return new SFTPFileService($config);
},
])
);
$df->addType(
new ServiceType([
'name' => 'webdav_file',
'label' => 'WebDAV File Storage',
'description' => 'File service supporting WebDAV.',
'group' => ServiceTypeGroups::FILE,
'config_handler' => WebDAVFileConfig::class,
'factory' => function ($config){
return new WebDAVFileService($config);
},
])
);
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"// merge in df config, https://laravel.com/docs/5.4/packages#resources",
"$",
"configPath",
"=",
"__DIR__",
".",
"'/../config/config.php'",
";",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"$",
"configPath",
",",
"'df'",
")",
";",
"// Add our service types.",
"$",
"this",
"->",
"app",
"->",
"resolving",
"(",
"'df.service'",
",",
"function",
"(",
"ServiceManager",
"$",
"df",
")",
"{",
"$",
"df",
"->",
"addType",
"(",
"new",
"ServiceType",
"(",
"[",
"'name'",
"=>",
"'local_file'",
",",
"'label'",
"=>",
"'Local File Storage'",
",",
"'description'",
"=>",
"'File service supporting the local file system.'",
",",
"'group'",
"=>",
"ServiceTypeGroups",
"::",
"FILE",
",",
"'config_handler'",
"=>",
"LocalFileConfig",
"::",
"class",
",",
"'factory'",
"=>",
"function",
"(",
"$",
"config",
")",
"{",
"return",
"new",
"LocalFileService",
"(",
"$",
"config",
")",
";",
"}",
",",
"]",
")",
")",
";",
"$",
"df",
"->",
"addType",
"(",
"new",
"ServiceType",
"(",
"[",
"'name'",
"=>",
"'ftp_file'",
",",
"'label'",
"=>",
"'FTP File Storage'",
",",
"'description'",
"=>",
"'File service supporting the FTP protocol.'",
",",
"'group'",
"=>",
"ServiceTypeGroups",
"::",
"FILE",
",",
"'config_handler'",
"=>",
"FTPFileConfig",
"::",
"class",
",",
"'factory'",
"=>",
"function",
"(",
"$",
"config",
")",
"{",
"return",
"new",
"FTPFileService",
"(",
"$",
"config",
")",
";",
"}",
",",
"]",
")",
")",
";",
"$",
"df",
"->",
"addType",
"(",
"new",
"ServiceType",
"(",
"[",
"'name'",
"=>",
"'sftp_file'",
",",
"'label'",
"=>",
"'SFTP File Storage'",
",",
"'description'",
"=>",
"'File service supporting the SFTP protocol.'",
",",
"'group'",
"=>",
"ServiceTypeGroups",
"::",
"FILE",
",",
"'config_handler'",
"=>",
"SFTPFileConfig",
"::",
"class",
",",
"'factory'",
"=>",
"function",
"(",
"$",
"config",
")",
"{",
"return",
"new",
"SFTPFileService",
"(",
"$",
"config",
")",
";",
"}",
",",
"]",
")",
")",
";",
"$",
"df",
"->",
"addType",
"(",
"new",
"ServiceType",
"(",
"[",
"'name'",
"=>",
"'webdav_file'",
",",
"'label'",
"=>",
"'WebDAV File Storage'",
",",
"'description'",
"=>",
"'File service supporting WebDAV.'",
",",
"'group'",
"=>",
"ServiceTypeGroups",
"::",
"FILE",
",",
"'config_handler'",
"=>",
"WebDAVFileConfig",
"::",
"class",
",",
"'factory'",
"=>",
"function",
"(",
"$",
"config",
")",
"{",
"return",
"new",
"WebDAVFileService",
"(",
"$",
"config",
")",
";",
"}",
",",
"]",
")",
")",
";",
"}",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/ServiceProvider.php#L49-L109 |
parsnick/steak | src/Console/ServeCommand.php | ServeCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->triggerInitialBuild($input, $output);
$this->startGulpWatcher($input, $output);
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->triggerInitialBuild($input, $output);
$this->startGulpWatcher($input, $output);
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"triggerInitialBuild",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"startGulpWatcher",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}"
] | Execute the command.
@param InputInterface $input
@param OutputInterface $output
@return void | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/ServeCommand.php#L34-L38 |
nyeholt/silverstripe-external-content | code/model/ExternalContentSource.php | ExternalContentSource.getCMSFields | public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('Sort');
$fields->removeByName('ParentID');
$fields->addFieldToTab('Root.Main', new TextField('Name', _t('ExternalContentSource.NAME', 'Name')));
$fields->addFieldToTab('Root.Main', new CheckboxField("ShowContentInMenu", _t('ExternalContentSource.SHOW_IN_MENUS', 'Show Content in Menus')));
return $fields;
} | php | public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('Sort');
$fields->removeByName('ParentID');
$fields->addFieldToTab('Root.Main', new TextField('Name', _t('ExternalContentSource.NAME', 'Name')));
$fields->addFieldToTab('Root.Main', new CheckboxField("ShowContentInMenu", _t('ExternalContentSource.SHOW_IN_MENUS', 'Show Content in Menus')));
return $fields;
} | [
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getCMSFields",
"(",
")",
";",
"$",
"fields",
"->",
"removeByName",
"(",
"'Sort'",
")",
";",
"$",
"fields",
"->",
"removeByName",
"(",
"'ParentID'",
")",
";",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Main'",
",",
"new",
"TextField",
"(",
"'Name'",
",",
"_t",
"(",
"'ExternalContentSource.NAME'",
",",
"'Name'",
")",
")",
")",
";",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Main'",
",",
"new",
"CheckboxField",
"(",
"\"ShowContentInMenu\"",
",",
"_t",
"(",
"'ExternalContentSource.SHOW_IN_MENUS'",
",",
"'Show Content in Menus'",
")",
")",
")",
";",
"return",
"$",
"fields",
";",
"}"
] | Child classes should provide connection details to the external
content source
@see sapphire/core/model/DataObject#getCMSFields($params)
@return FieldSet | [
"Child",
"classes",
"should",
"provide",
"connection",
"details",
"to",
"the",
"external",
"content",
"source"
] | train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentSource.php#L94-L103 |
nyeholt/silverstripe-external-content | code/model/ExternalContentSource.php | ExternalContentSource.stageChildren | public function stageChildren($showAll = false) {
// if we don't have an ID directly, we should load and return ALL the external content sources
if (!$this->ID) {
return DataObject::get('ExternalContentSource');
}
$children = new ArrayList();
return $children;
} | php | public function stageChildren($showAll = false) {
// if we don't have an ID directly, we should load and return ALL the external content sources
if (!$this->ID) {
return DataObject::get('ExternalContentSource');
}
$children = new ArrayList();
return $children;
} | [
"public",
"function",
"stageChildren",
"(",
"$",
"showAll",
"=",
"false",
")",
"{",
"// if we don't have an ID directly, we should load and return ALL the external content sources",
"if",
"(",
"!",
"$",
"this",
"->",
"ID",
")",
"{",
"return",
"DataObject",
"::",
"get",
"(",
"'ExternalContentSource'",
")",
";",
"}",
"$",
"children",
"=",
"new",
"ArrayList",
"(",
")",
";",
"return",
"$",
"children",
";",
"}"
] | Override to return the top level content items from the remote
content source.
Specific implementations should effectively query the remote
source for all items that are children of the 'root' node.
@param boolean $showAll
@return DataObjectSet | [
"Override",
"to",
"return",
"the",
"top",
"level",
"content",
"items",
"from",
"the",
"remote",
"content",
"source",
"."
] | train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentSource.php#L210-L218 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.rotate | private static function rotate($word){
$c = $word[0];
for ($i = 0; $i < 3; $i++)
$word[$i] = $word[$i+1];
$word[3] = $c;
return $word;
} | php | private static function rotate($word){
$c = $word[0];
for ($i = 0; $i < 3; $i++)
$word[$i] = $word[$i+1];
$word[3] = $c;
return $word;
} | [
"private",
"static",
"function",
"rotate",
"(",
"$",
"word",
")",
"{",
"$",
"c",
"=",
"$",
"word",
"[",
"0",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"$",
"word",
"[",
"$",
"i",
"]",
"=",
"$",
"word",
"[",
"$",
"i",
"+",
"1",
"]",
";",
"$",
"word",
"[",
"3",
"]",
"=",
"$",
"c",
";",
"return",
"$",
"word",
";",
"}"
] | /* rotate the word eight bits to the left | [
"/",
"*",
"rotate",
"the",
"word",
"eight",
"bits",
"to",
"the",
"left"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L75-L82 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.core | private static function core($word,$iteration){
/* rotate the 32-bit word 8 bits to the left */
$word = self::rotate($word);
/* apply S-Box substitution on all 4 parts of the 32-bit word */
for ($i = 0; $i < 4; ++$i)
$word[$i] = self::$sbox[$word[$i]];
/* XOR the output of the rcon operation with i to the first part (leftmost) only */
$word[0] = $word[0]^self::$Rcon[$iteration];
return $word;
} | php | private static function core($word,$iteration){
/* rotate the 32-bit word 8 bits to the left */
$word = self::rotate($word);
/* apply S-Box substitution on all 4 parts of the 32-bit word */
for ($i = 0; $i < 4; ++$i)
$word[$i] = self::$sbox[$word[$i]];
/* XOR the output of the rcon operation with i to the first part (leftmost) only */
$word[0] = $word[0]^self::$Rcon[$iteration];
return $word;
} | [
"private",
"static",
"function",
"core",
"(",
"$",
"word",
",",
"$",
"iteration",
")",
"{",
"/* rotate the 32-bit word 8 bits to the left */",
"$",
"word",
"=",
"self",
"::",
"rotate",
"(",
"$",
"word",
")",
";",
"/* apply S-Box substitution on all 4 parts of the 32-bit word */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"4",
";",
"++",
"$",
"i",
")",
"$",
"word",
"[",
"$",
"i",
"]",
"=",
"self",
"::",
"$",
"sbox",
"[",
"$",
"word",
"[",
"$",
"i",
"]",
"]",
";",
"/* XOR the output of the rcon operation with i to the first part (leftmost) only */",
"$",
"word",
"[",
"0",
"]",
"=",
"$",
"word",
"[",
"0",
"]",
"^",
"self",
"::",
"$",
"Rcon",
"[",
"$",
"iteration",
"]",
";",
"return",
"$",
"word",
";",
"}"
] | Key Schedule Core | [
"Key",
"Schedule",
"Core"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L259-L268 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.expandKey | private static function expandKey($key,$size)
{
$expandedKeySize = (16*(self::numberOfRounds($size)+1));
/* current expanded keySize, in bytes */
$currentSize = 0;
$rconIteration = 1;
$t = array(); // temporary 4-byte variable
$expandedKey = array();
for($i = 0;$i < $expandedKeySize;$i++)
$expandedKey[$i] = 0;
/* set the 16,24,32 bytes of the expanded key to the input key */
for ($j = 0; $j < $size; $j++)
$expandedKey[$j] = $key[$j];
$currentSize += $size;
while ($currentSize < $expandedKeySize)
{
/* assign the previous 4 bytes to the temporary value t */
for ($k = 0; $k < 4; $k++)
$t[$k] = $expandedKey[($currentSize - 4) + $k];
/* every 16,24,32 bytes we apply the core schedule to t
* and increment rconIteration afterwards
*/
if($currentSize % $size == 0)
$t = self::core($t, $rconIteration++);
/* For 256-bit keys, we add an extra sbox to the calculation */
if($size == self::keySize_256 && (($currentSize % $size) == 16))
for($l = 0; $l < 4; $l++)
$t[$l] = self::$sbox[$t[$l]];
/* We XOR t with the four-byte block 16,24,32 bytes before the new expanded key.
* This becomes the next four bytes in the expanded key.
*/
for($m = 0; $m < 4; $m++) {
$expandedKey[$currentSize] = $expandedKey[$currentSize - $size] ^ $t[$m];
$currentSize++;
}
}
return $expandedKey;
} | php | private static function expandKey($key,$size)
{
$expandedKeySize = (16*(self::numberOfRounds($size)+1));
/* current expanded keySize, in bytes */
$currentSize = 0;
$rconIteration = 1;
$t = array(); // temporary 4-byte variable
$expandedKey = array();
for($i = 0;$i < $expandedKeySize;$i++)
$expandedKey[$i] = 0;
/* set the 16,24,32 bytes of the expanded key to the input key */
for ($j = 0; $j < $size; $j++)
$expandedKey[$j] = $key[$j];
$currentSize += $size;
while ($currentSize < $expandedKeySize)
{
/* assign the previous 4 bytes to the temporary value t */
for ($k = 0; $k < 4; $k++)
$t[$k] = $expandedKey[($currentSize - 4) + $k];
/* every 16,24,32 bytes we apply the core schedule to t
* and increment rconIteration afterwards
*/
if($currentSize % $size == 0)
$t = self::core($t, $rconIteration++);
/* For 256-bit keys, we add an extra sbox to the calculation */
if($size == self::keySize_256 && (($currentSize % $size) == 16))
for($l = 0; $l < 4; $l++)
$t[$l] = self::$sbox[$t[$l]];
/* We XOR t with the four-byte block 16,24,32 bytes before the new expanded key.
* This becomes the next four bytes in the expanded key.
*/
for($m = 0; $m < 4; $m++) {
$expandedKey[$currentSize] = $expandedKey[$currentSize - $size] ^ $t[$m];
$currentSize++;
}
}
return $expandedKey;
} | [
"private",
"static",
"function",
"expandKey",
"(",
"$",
"key",
",",
"$",
"size",
")",
"{",
"$",
"expandedKeySize",
"=",
"(",
"16",
"*",
"(",
"self",
"::",
"numberOfRounds",
"(",
"$",
"size",
")",
"+",
"1",
")",
")",
";",
"/* current expanded keySize, in bytes */",
"$",
"currentSize",
"=",
"0",
";",
"$",
"rconIteration",
"=",
"1",
";",
"$",
"t",
"=",
"array",
"(",
")",
";",
"// temporary 4-byte variable",
"$",
"expandedKey",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"expandedKeySize",
";",
"$",
"i",
"++",
")",
"$",
"expandedKey",
"[",
"$",
"i",
"]",
"=",
"0",
";",
"/* set the 16,24,32 bytes of the expanded key to the input key */",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"size",
";",
"$",
"j",
"++",
")",
"$",
"expandedKey",
"[",
"$",
"j",
"]",
"=",
"$",
"key",
"[",
"$",
"j",
"]",
";",
"$",
"currentSize",
"+=",
"$",
"size",
";",
"while",
"(",
"$",
"currentSize",
"<",
"$",
"expandedKeySize",
")",
"{",
"/* assign the previous 4 bytes to the temporary value t */",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"4",
";",
"$",
"k",
"++",
")",
"$",
"t",
"[",
"$",
"k",
"]",
"=",
"$",
"expandedKey",
"[",
"(",
"$",
"currentSize",
"-",
"4",
")",
"+",
"$",
"k",
"]",
";",
"/* every 16,24,32 bytes we apply the core schedule to t\n\t\t\t * and increment rconIteration afterwards\n\t\t\t */",
"if",
"(",
"$",
"currentSize",
"%",
"$",
"size",
"==",
"0",
")",
"$",
"t",
"=",
"self",
"::",
"core",
"(",
"$",
"t",
",",
"$",
"rconIteration",
"++",
")",
";",
"/* For 256-bit keys, we add an extra sbox to the calculation */",
"if",
"(",
"$",
"size",
"==",
"self",
"::",
"keySize_256",
"&&",
"(",
"(",
"$",
"currentSize",
"%",
"$",
"size",
")",
"==",
"16",
")",
")",
"for",
"(",
"$",
"l",
"=",
"0",
";",
"$",
"l",
"<",
"4",
";",
"$",
"l",
"++",
")",
"$",
"t",
"[",
"$",
"l",
"]",
"=",
"self",
"::",
"$",
"sbox",
"[",
"$",
"t",
"[",
"$",
"l",
"]",
"]",
";",
"/* We XOR t with the four-byte block 16,24,32 bytes before the new expanded key.\n\t\t\t * This becomes the next four bytes in the expanded key.\n\t\t\t */",
"for",
"(",
"$",
"m",
"=",
"0",
";",
"$",
"m",
"<",
"4",
";",
"$",
"m",
"++",
")",
"{",
"$",
"expandedKey",
"[",
"$",
"currentSize",
"]",
"=",
"$",
"expandedKey",
"[",
"$",
"currentSize",
"-",
"$",
"size",
"]",
"^",
"$",
"t",
"[",
"$",
"m",
"]",
";",
"$",
"currentSize",
"++",
";",
"}",
"}",
"return",
"$",
"expandedKey",
";",
"}"
] | /* Rijndael's key expansion
expands an 128,192,256 key into an 176,208,240 bytes key
expandedKey is a pointer to an char array of large enough size
key is a pointer to a non-expanded key | [
"/",
"*",
"Rijndael",
"s",
"key",
"expansion",
"expands",
"an",
"128",
"192",
"256",
"key",
"into",
"an",
"176",
"208",
"240",
"bytes",
"key"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L276-L320 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.addRoundKey | private static function addRoundKey($state,$roundKey){
for ($i = 0; $i < 16; $i++)
$state[$i] = $state[$i] ^ $roundKey[$i];
return $state;
} | php | private static function addRoundKey($state,$roundKey){
for ($i = 0; $i < 16; $i++)
$state[$i] = $state[$i] ^ $roundKey[$i];
return $state;
} | [
"private",
"static",
"function",
"addRoundKey",
"(",
"$",
"state",
",",
"$",
"roundKey",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"state",
"[",
"$",
"i",
"]",
"=",
"$",
"state",
"[",
"$",
"i",
"]",
"^",
"$",
"roundKey",
"[",
"$",
"i",
"]",
";",
"return",
"$",
"state",
";",
"}"
] | Adds (XORs) the round key to the state | [
"Adds",
"(",
"XORs",
")",
"the",
"round",
"key",
"to",
"the",
"state"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L323-L327 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.createRoundKey | private static function createRoundKey($expandedKey,$roundKeyPointer){
$roundKey = array();
for ($i = 0; $i < 4; $i++)
for ($j = 0; $j < 4; $j++)
$roundKey[$j*4+$i] = $expandedKey[$roundKeyPointer + $i*4 + $j];
return $roundKey;
} | php | private static function createRoundKey($expandedKey,$roundKeyPointer){
$roundKey = array();
for ($i = 0; $i < 4; $i++)
for ($j = 0; $j < 4; $j++)
$roundKey[$j*4+$i] = $expandedKey[$roundKeyPointer + $i*4 + $j];
return $roundKey;
} | [
"private",
"static",
"function",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"$",
"roundKeyPointer",
")",
"{",
"$",
"roundKey",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"4",
";",
"$",
"i",
"++",
")",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"4",
";",
"$",
"j",
"++",
")",
"$",
"roundKey",
"[",
"$",
"j",
"*",
"4",
"+",
"$",
"i",
"]",
"=",
"$",
"expandedKey",
"[",
"$",
"roundKeyPointer",
"+",
"$",
"i",
"*",
"4",
"+",
"$",
"j",
"]",
";",
"return",
"$",
"roundKey",
";",
"}"
] | position within the expanded key. | [
"position",
"within",
"the",
"expanded",
"key",
"."
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L331-L337 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.subBytes | private static function subBytes($state,$isInv){
for ($i = 0; $i < 16; $i++)
$state[$i] = $isInv?self::$rsbox[$state[$i]]:self::$sbox[$state[$i]];
return $state;
} | php | private static function subBytes($state,$isInv){
for ($i = 0; $i < 16; $i++)
$state[$i] = $isInv?self::$rsbox[$state[$i]]:self::$sbox[$state[$i]];
return $state;
} | [
"private",
"static",
"function",
"subBytes",
"(",
"$",
"state",
",",
"$",
"isInv",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"state",
"[",
"$",
"i",
"]",
"=",
"$",
"isInv",
"?",
"self",
"::",
"$",
"rsbox",
"[",
"$",
"state",
"[",
"$",
"i",
"]",
"]",
":",
"self",
"::",
"$",
"sbox",
"[",
"$",
"state",
"[",
"$",
"i",
"]",
"]",
";",
"return",
"$",
"state",
";",
"}"
] | /* substitute all the values from the state with the value in the SBox
using the state value as index for the SBox | [
"/",
"*",
"substitute",
"all",
"the",
"values",
"from",
"the",
"state",
"with",
"the",
"value",
"in",
"the",
"SBox",
"using",
"the",
"state",
"value",
"as",
"index",
"for",
"the",
"SBox"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L342-L346 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.shiftRows | private static function shiftRows($state,$isInv){
for ($i = 0; $i < 4; $i++)
$state = self::shiftRow($state,$i*4, $i,$isInv);
return $state;
} | php | private static function shiftRows($state,$isInv){
for ($i = 0; $i < 4; $i++)
$state = self::shiftRow($state,$i*4, $i,$isInv);
return $state;
} | [
"private",
"static",
"function",
"shiftRows",
"(",
"$",
"state",
",",
"$",
"isInv",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"4",
";",
"$",
"i",
"++",
")",
"$",
"state",
"=",
"self",
"::",
"shiftRow",
"(",
"$",
"state",
",",
"$",
"i",
"*",
"4",
",",
"$",
"i",
",",
"$",
"isInv",
")",
";",
"return",
"$",
"state",
";",
"}"
] | /* iterate over the 4 rows and call shiftRow() with that row | [
"/",
"*",
"iterate",
"over",
"the",
"4",
"rows",
"and",
"call",
"shiftRow",
"()",
"with",
"that",
"row"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L349-L353 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.shiftRow | private static function shiftRow($state,$statePointer,$nbr,$isInv){
for ($i = 0; $i < $nbr; $i++)
{
if($isInv)
{
$tmp = $state[$statePointer + 3];
for ($j = 3; $j > 0; $j--)
$state[$statePointer + $j] = $state[$statePointer + $j-1];
$state[$statePointer] = $tmp;
}
else
{
$tmp = $state[$statePointer];
for ($j = 0; $j < 3; $j++)
$state[$statePointer + $j] = $state[$statePointer + $j+1];
$state[$statePointer + 3] = $tmp;
}
}
return $state;
} | php | private static function shiftRow($state,$statePointer,$nbr,$isInv){
for ($i = 0; $i < $nbr; $i++)
{
if($isInv)
{
$tmp = $state[$statePointer + 3];
for ($j = 3; $j > 0; $j--)
$state[$statePointer + $j] = $state[$statePointer + $j-1];
$state[$statePointer] = $tmp;
}
else
{
$tmp = $state[$statePointer];
for ($j = 0; $j < 3; $j++)
$state[$statePointer + $j] = $state[$statePointer + $j+1];
$state[$statePointer + 3] = $tmp;
}
}
return $state;
} | [
"private",
"static",
"function",
"shiftRow",
"(",
"$",
"state",
",",
"$",
"statePointer",
",",
"$",
"nbr",
",",
"$",
"isInv",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"nbr",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"isInv",
")",
"{",
"$",
"tmp",
"=",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"3",
"]",
";",
"for",
"(",
"$",
"j",
"=",
"3",
";",
"$",
"j",
">",
"0",
";",
"$",
"j",
"--",
")",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"$",
"j",
"]",
"=",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"$",
"j",
"-",
"1",
"]",
";",
"$",
"state",
"[",
"$",
"statePointer",
"]",
"=",
"$",
"tmp",
";",
"}",
"else",
"{",
"$",
"tmp",
"=",
"$",
"state",
"[",
"$",
"statePointer",
"]",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"3",
";",
"$",
"j",
"++",
")",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"$",
"j",
"]",
"=",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"$",
"j",
"+",
"1",
"]",
";",
"$",
"state",
"[",
"$",
"statePointer",
"+",
"3",
"]",
"=",
"$",
"tmp",
";",
"}",
"}",
"return",
"$",
"state",
";",
"}"
] | /* each iteration shifts the row to the left by 1 | [
"/",
"*",
"each",
"iteration",
"shifts",
"the",
"row",
"to",
"the",
"left",
"by",
"1"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L356-L375 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.mixColumns | private static function mixColumns($state,$isInv){
$t = array();
if (!$isInv) {
for ($c = 0; $c < 4; $c++) {
$t[ $c] = self::$G2X[$state[$c]] ^ self::$G3X[$state[4+$c]] ^ $state[8+$c] ^ $state[12+$c];
$t[ 4+$c] = $state[$c] ^ self::$G2X[$state[4+$c]] ^ self::$G3X[$state[8+$c]] ^ $state[12+$c];
$t[ 8+$c] = $state[$c] ^ $state[4+$c] ^ self::$G2X[$state[8+$c]] ^ self::$G3X[$state[12+$c]];
$t[12+$c] = self::$G3X[$state[$c]] ^ $state[4+$c] ^ $state[8+$c] ^ self::$G2X[$state[12+$c]];
}
}else {
for ($c = 0; $c < 16; $c+=4) {
$t[ $c] = self::$GEX[$state[$c]] ^ self::$GBX[$state[4+$c]] ^ self::$GDX[$state[8+$c]] ^ self::$G9X[$state[12+$c]];
$t[1+$c] = self::$G9X[$state[$c]] ^ self::$GEX[$state[4+$c]] ^ self::$GBX[$state[8+$c]] ^ self::$GDX[$state[12+$c]];
$t[2+$c] = self::$GDX[$state[$c]] ^ self::$G9X[$state[4+$c]] ^ self::$GEX[$state[8+$c]] ^ self::$GBX[$state[12+$c]];
$t[3+$c] = self::$GBX[$state[$c]] ^ self::$GDX[$state[4+$c]] ^ self::$G9X[$state[8+$c]] ^ self::$GEX[$state[12+$c]];
}
}
return $t;
} | php | private static function mixColumns($state,$isInv){
$t = array();
if (!$isInv) {
for ($c = 0; $c < 4; $c++) {
$t[ $c] = self::$G2X[$state[$c]] ^ self::$G3X[$state[4+$c]] ^ $state[8+$c] ^ $state[12+$c];
$t[ 4+$c] = $state[$c] ^ self::$G2X[$state[4+$c]] ^ self::$G3X[$state[8+$c]] ^ $state[12+$c];
$t[ 8+$c] = $state[$c] ^ $state[4+$c] ^ self::$G2X[$state[8+$c]] ^ self::$G3X[$state[12+$c]];
$t[12+$c] = self::$G3X[$state[$c]] ^ $state[4+$c] ^ $state[8+$c] ^ self::$G2X[$state[12+$c]];
}
}else {
for ($c = 0; $c < 16; $c+=4) {
$t[ $c] = self::$GEX[$state[$c]] ^ self::$GBX[$state[4+$c]] ^ self::$GDX[$state[8+$c]] ^ self::$G9X[$state[12+$c]];
$t[1+$c] = self::$G9X[$state[$c]] ^ self::$GEX[$state[4+$c]] ^ self::$GBX[$state[8+$c]] ^ self::$GDX[$state[12+$c]];
$t[2+$c] = self::$GDX[$state[$c]] ^ self::$G9X[$state[4+$c]] ^ self::$GEX[$state[8+$c]] ^ self::$GBX[$state[12+$c]];
$t[3+$c] = self::$GBX[$state[$c]] ^ self::$GDX[$state[4+$c]] ^ self::$G9X[$state[8+$c]] ^ self::$GEX[$state[12+$c]];
}
}
return $t;
} | [
"private",
"static",
"function",
"mixColumns",
"(",
"$",
"state",
",",
"$",
"isInv",
")",
"{",
"$",
"t",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"isInv",
")",
"{",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"4",
";",
"$",
"c",
"++",
")",
"{",
"$",
"t",
"[",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"G2X",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G3X",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"^",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
";",
"$",
"t",
"[",
"4",
"+",
"$",
"c",
"]",
"=",
"$",
"state",
"[",
"$",
"c",
"]",
"^",
"self",
"::",
"$",
"G2X",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G3X",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
";",
"$",
"t",
"[",
"8",
"+",
"$",
"c",
"]",
"=",
"$",
"state",
"[",
"$",
"c",
"]",
"^",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"^",
"self",
"::",
"$",
"G2X",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G3X",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"$",
"t",
"[",
"12",
"+",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"G3X",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"^",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"^",
"self",
"::",
"$",
"G2X",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"16",
";",
"$",
"c",
"+=",
"4",
")",
"{",
"$",
"t",
"[",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"GEX",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GBX",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GDX",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G9X",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"$",
"t",
"[",
"1",
"+",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"G9X",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GEX",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GBX",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GDX",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"$",
"t",
"[",
"2",
"+",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"GDX",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G9X",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GEX",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GBX",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"$",
"t",
"[",
"3",
"+",
"$",
"c",
"]",
"=",
"self",
"::",
"$",
"GBX",
"[",
"$",
"state",
"[",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GDX",
"[",
"$",
"state",
"[",
"4",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"G9X",
"[",
"$",
"state",
"[",
"8",
"+",
"$",
"c",
"]",
"]",
"^",
"self",
"::",
"$",
"GEX",
"[",
"$",
"state",
"[",
"12",
"+",
"$",
"c",
"]",
"]",
";",
"}",
"}",
"return",
"$",
"t",
";",
"}"
] | galois multipication of the 4x4 matrix | [
"galois",
"multipication",
"of",
"the",
"4x4",
"matrix"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L378-L398 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.round | private static function round($state, $roundKey){
$state = self::subBytes($state,false);
$state = self::shiftRows($state,false);
$state = self::mixColumns($state,false);
$state = self::addRoundKey($state, $roundKey);
return $state;
} | php | private static function round($state, $roundKey){
$state = self::subBytes($state,false);
$state = self::shiftRows($state,false);
$state = self::mixColumns($state,false);
$state = self::addRoundKey($state, $roundKey);
return $state;
} | [
"private",
"static",
"function",
"round",
"(",
"$",
"state",
",",
"$",
"roundKey",
")",
"{",
"$",
"state",
"=",
"self",
"::",
"subBytes",
"(",
"$",
"state",
",",
"false",
")",
";",
"$",
"state",
"=",
"self",
"::",
"shiftRows",
"(",
"$",
"state",
",",
"false",
")",
";",
"$",
"state",
"=",
"self",
"::",
"mixColumns",
"(",
"$",
"state",
",",
"false",
")",
";",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"$",
"roundKey",
")",
";",
"return",
"$",
"state",
";",
"}"
] | applies the 4 operations of the forward round in sequence | [
"applies",
"the",
"4",
"operations",
"of",
"the",
"forward",
"round",
"in",
"sequence"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L401-L407 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.invRound | private static function invRound($state,$roundKey){
$state = self::shiftRows($state,true);
$state = self::subBytes($state,true);
$state = self::addRoundKey($state, $roundKey);
$state = self::mixColumns($state,true);
return $state;
} | php | private static function invRound($state,$roundKey){
$state = self::shiftRows($state,true);
$state = self::subBytes($state,true);
$state = self::addRoundKey($state, $roundKey);
$state = self::mixColumns($state,true);
return $state;
} | [
"private",
"static",
"function",
"invRound",
"(",
"$",
"state",
",",
"$",
"roundKey",
")",
"{",
"$",
"state",
"=",
"self",
"::",
"shiftRows",
"(",
"$",
"state",
",",
"true",
")",
";",
"$",
"state",
"=",
"self",
"::",
"subBytes",
"(",
"$",
"state",
",",
"true",
")",
";",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"$",
"roundKey",
")",
";",
"$",
"state",
"=",
"self",
"::",
"mixColumns",
"(",
"$",
"state",
",",
"true",
")",
";",
"return",
"$",
"state",
";",
"}"
] | applies the 4 operations of the inverse round in sequence | [
"applies",
"the",
"4",
"operations",
"of",
"the",
"inverse",
"round",
"in",
"sequence"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L410-L416 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.main | private static function main($state,$expandedKey,$nbrRounds){
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
for ($i = 1; $i < $nbrRounds; $i++)
$state = self::round($state, self::createRoundKey($expandedKey,16*$i));
$state = self::subBytes($state,false);
$state = self::shiftRows($state,false);
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
return $state;
} | php | private static function main($state,$expandedKey,$nbrRounds){
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
for ($i = 1; $i < $nbrRounds; $i++)
$state = self::round($state, self::createRoundKey($expandedKey,16*$i));
$state = self::subBytes($state,false);
$state = self::shiftRows($state,false);
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
return $state;
} | [
"private",
"static",
"function",
"main",
"(",
"$",
"state",
",",
"$",
"expandedKey",
",",
"$",
"nbrRounds",
")",
"{",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"0",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"nbrRounds",
";",
"$",
"i",
"++",
")",
"$",
"state",
"=",
"self",
"::",
"round",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"16",
"*",
"$",
"i",
")",
")",
";",
"$",
"state",
"=",
"self",
"::",
"subBytes",
"(",
"$",
"state",
",",
"false",
")",
";",
"$",
"state",
"=",
"self",
"::",
"shiftRows",
"(",
"$",
"state",
",",
"false",
")",
";",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"16",
"*",
"$",
"nbrRounds",
")",
")",
";",
"return",
"$",
"state",
";",
"}"
] | /*
Perform the initial operations, the standard round, and the final operations
of the forward aes, creating a round key for each round | [
"/",
"*",
"Perform",
"the",
"initial",
"operations",
"the",
"standard",
"round",
"and",
"the",
"final",
"operations",
"of",
"the",
"forward",
"aes",
"creating",
"a",
"round",
"key",
"for",
"each",
"round"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L422-L430 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.invMain | private static function invMain($state, $expandedKey, $nbrRounds){
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
for ($i = $nbrRounds-1; $i > 0; $i--)
$state = self::invRound($state, self::createRoundKey($expandedKey,16*i));
$state = self::shiftRows($state,true);
$state = self::subBytes($state,true);
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
return $state;
} | php | private static function invMain($state, $expandedKey, $nbrRounds){
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
for ($i = $nbrRounds-1; $i > 0; $i--)
$state = self::invRound($state, self::createRoundKey($expandedKey,16*i));
$state = self::shiftRows($state,true);
$state = self::subBytes($state,true);
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
return $state;
} | [
"private",
"static",
"function",
"invMain",
"(",
"$",
"state",
",",
"$",
"expandedKey",
",",
"$",
"nbrRounds",
")",
"{",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"16",
"*",
"$",
"nbrRounds",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"nbrRounds",
"-",
"1",
";",
"$",
"i",
">",
"0",
";",
"$",
"i",
"--",
")",
"$",
"state",
"=",
"self",
"::",
"invRound",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"16",
"*",
"i",
")",
")",
";",
"$",
"state",
"=",
"self",
"::",
"shiftRows",
"(",
"$",
"state",
",",
"true",
")",
";",
"$",
"state",
"=",
"self",
"::",
"subBytes",
"(",
"$",
"state",
",",
"true",
")",
";",
"$",
"state",
"=",
"self",
"::",
"addRoundKey",
"(",
"$",
"state",
",",
"self",
"::",
"createRoundKey",
"(",
"$",
"expandedKey",
",",
"0",
")",
")",
";",
"return",
"$",
"state",
";",
"}"
] | /*
Perform the initial operations, the standard round, and the final operations
of the inverse aes, creating a round key for each round | [
"/",
"*",
"Perform",
"the",
"initial",
"operations",
"the",
"standard",
"round",
"and",
"the",
"final",
"operations",
"of",
"the",
"inverse",
"aes",
"creating",
"a",
"round",
"key",
"for",
"each",
"round"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L436-L444 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.encryptBlock | private static function encryptBlock($input,$key,$size){
$output = array();
$block = array(); /* the 128 bit block to encode */
$nbrRounds = self::numberOfRounds($size);
/* Set the block values, for the block:
* a0,0 a0,1 a0,2 a0,3
* a1,0 a1,1 a1,2 a1,3
* a2,0 a2,1 a2,2 a2,3
* a3,0 a3,1 a3,2 a3,3
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
*/
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
$block[($i+($j*4))] = $input[($i*4)+$j];
/* expand the key into an 176, 208, 240 bytes key */
$expandedKey = self::expandKey($key, $size); /* the expanded key */
/* encrypt the block using the expandedKey */
$block = self::main($block, $expandedKey, $nbrRounds);
for ($k = 0; $k < 4; $k++) /* unmap the block again into the output */
for ($l = 0; $l < 4; $l++) /* iterate over the rows */
$output[($k*4)+$l] = $block[($k+($l*4))];
return $output;
} | php | private static function encryptBlock($input,$key,$size){
$output = array();
$block = array(); /* the 128 bit block to encode */
$nbrRounds = self::numberOfRounds($size);
/* Set the block values, for the block:
* a0,0 a0,1 a0,2 a0,3
* a1,0 a1,1 a1,2 a1,3
* a2,0 a2,1 a2,2 a2,3
* a3,0 a3,1 a3,2 a3,3
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
*/
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
$block[($i+($j*4))] = $input[($i*4)+$j];
/* expand the key into an 176, 208, 240 bytes key */
$expandedKey = self::expandKey($key, $size); /* the expanded key */
/* encrypt the block using the expandedKey */
$block = self::main($block, $expandedKey, $nbrRounds);
for ($k = 0; $k < 4; $k++) /* unmap the block again into the output */
for ($l = 0; $l < 4; $l++) /* iterate over the rows */
$output[($k*4)+$l] = $block[($k+($l*4))];
return $output;
} | [
"private",
"static",
"function",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"block",
"=",
"array",
"(",
")",
";",
"/* the 128 bit block to encode */",
"$",
"nbrRounds",
"=",
"self",
"::",
"numberOfRounds",
"(",
"$",
"size",
")",
";",
"/* Set the block values, for the block:\n\t\t * a0,0 a0,1 a0,2 a0,3\n\t\t * a1,0 a1,1 a1,2 a1,3\n\t\t * a2,0 a2,1 a2,2 a2,3\n\t\t * a3,0 a3,1 a3,2 a3,3\n\t\t * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3\n\t\t */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"4",
";",
"$",
"i",
"++",
")",
"/* iterate over the columns */",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"4",
";",
"$",
"j",
"++",
")",
"/* iterate over the rows */",
"$",
"block",
"[",
"(",
"$",
"i",
"+",
"(",
"$",
"j",
"*",
"4",
")",
")",
"]",
"=",
"$",
"input",
"[",
"(",
"$",
"i",
"*",
"4",
")",
"+",
"$",
"j",
"]",
";",
"/* expand the key into an 176, 208, 240 bytes key */",
"$",
"expandedKey",
"=",
"self",
"::",
"expandKey",
"(",
"$",
"key",
",",
"$",
"size",
")",
";",
"/* the expanded key */",
"/* encrypt the block using the expandedKey */",
"$",
"block",
"=",
"self",
"::",
"main",
"(",
"$",
"block",
",",
"$",
"expandedKey",
",",
"$",
"nbrRounds",
")",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"4",
";",
"$",
"k",
"++",
")",
"/* unmap the block again into the output */",
"for",
"(",
"$",
"l",
"=",
"0",
";",
"$",
"l",
"<",
"4",
";",
"$",
"l",
"++",
")",
"/* iterate over the rows */",
"$",
"output",
"[",
"(",
"$",
"k",
"*",
"4",
")",
"+",
"$",
"l",
"]",
"=",
"$",
"block",
"[",
"(",
"$",
"k",
"+",
"(",
"$",
"l",
"*",
"4",
")",
")",
"]",
";",
"return",
"$",
"output",
";",
"}"
] | encrypts a 128 bit input block against the given key of size specified | [
"encrypts",
"a",
"128",
"bit",
"input",
"block",
"against",
"the",
"given",
"key",
"of",
"size",
"specified"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L467-L490 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.decryptBlock | private static function decryptBlock($input, $key, $size){
$output = array();
$block = array(); /* the 128 bit block to decode */
$nbrRounds = self::numberOfRounds($size);
/* Set the block values, for the block:
* a0,0 a0,1 a0,2 a0,3
* a1,0 a1,1 a1,2 a1,3
* a2,0 a2,1 a2,2 a2,3
* a3,0 a3,1 a3,2 a3,3
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
*/
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
$block[($i+($j*4))] = $input[($i*4)+$j];
/* expand the key into an 176, 208, 240 bytes key */
$expandedKey = self::expandKey($key, $size);
/* decrypt the block using the expandedKey */
$block = self::invMain($block, $expandedKey, $nbrRounds);
for ($k = 0; $k < 4; $k++)/* unmap the block again into the output */
for ($l = 0; $l < 4; $l++)/* iterate over the rows */
$output[($k*4)+$l] = $block[($k+($l*4))];
return $output;
} | php | private static function decryptBlock($input, $key, $size){
$output = array();
$block = array(); /* the 128 bit block to decode */
$nbrRounds = self::numberOfRounds($size);
/* Set the block values, for the block:
* a0,0 a0,1 a0,2 a0,3
* a1,0 a1,1 a1,2 a1,3
* a2,0 a2,1 a2,2 a2,3
* a3,0 a3,1 a3,2 a3,3
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
*/
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
$block[($i+($j*4))] = $input[($i*4)+$j];
/* expand the key into an 176, 208, 240 bytes key */
$expandedKey = self::expandKey($key, $size);
/* decrypt the block using the expandedKey */
$block = self::invMain($block, $expandedKey, $nbrRounds);
for ($k = 0; $k < 4; $k++)/* unmap the block again into the output */
for ($l = 0; $l < 4; $l++)/* iterate over the rows */
$output[($k*4)+$l] = $block[($k+($l*4))];
return $output;
} | [
"private",
"static",
"function",
"decryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"block",
"=",
"array",
"(",
")",
";",
"/* the 128 bit block to decode */",
"$",
"nbrRounds",
"=",
"self",
"::",
"numberOfRounds",
"(",
"$",
"size",
")",
";",
"/* Set the block values, for the block:\n\t\t * a0,0 a0,1 a0,2 a0,3\n\t\t * a1,0 a1,1 a1,2 a1,3\n\t\t * a2,0 a2,1 a2,2 a2,3\n\t\t * a3,0 a3,1 a3,2 a3,3\n\t\t * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3\n\t\t */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"4",
";",
"$",
"i",
"++",
")",
"/* iterate over the columns */",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"4",
";",
"$",
"j",
"++",
")",
"/* iterate over the rows */",
"$",
"block",
"[",
"(",
"$",
"i",
"+",
"(",
"$",
"j",
"*",
"4",
")",
")",
"]",
"=",
"$",
"input",
"[",
"(",
"$",
"i",
"*",
"4",
")",
"+",
"$",
"j",
"]",
";",
"/* expand the key into an 176, 208, 240 bytes key */",
"$",
"expandedKey",
"=",
"self",
"::",
"expandKey",
"(",
"$",
"key",
",",
"$",
"size",
")",
";",
"/* decrypt the block using the expandedKey */",
"$",
"block",
"=",
"self",
"::",
"invMain",
"(",
"$",
"block",
",",
"$",
"expandedKey",
",",
"$",
"nbrRounds",
")",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"4",
";",
"$",
"k",
"++",
")",
"/* unmap the block again into the output */",
"for",
"(",
"$",
"l",
"=",
"0",
";",
"$",
"l",
"<",
"4",
";",
"$",
"l",
"++",
")",
"/* iterate over the rows */",
"$",
"output",
"[",
"(",
"$",
"k",
"*",
"4",
")",
"+",
"$",
"l",
"]",
"=",
"$",
"block",
"[",
"(",
"$",
"k",
"+",
"(",
"$",
"l",
"*",
"4",
")",
")",
"]",
";",
"return",
"$",
"output",
";",
"}"
] | decrypts a 128 bit input block against the given key of size specified | [
"decrypts",
"a",
"128",
"bit",
"input",
"block",
"against",
"the",
"given",
"key",
"of",
"size",
"specified"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L493-L515 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.getPaddedBlock | private static function getPaddedBlock($bytesIn,$start,$end,$mode){
if($end - $start > 16)
$end = $start + 16;
$xarray = array_slice($bytesIn, $start, $end-$start);
$cpad = 16 - count($xarray);
while(count($xarray) < 16){
array_push($xarray, $cpad);
}
return $xarray;
} | php | private static function getPaddedBlock($bytesIn,$start,$end,$mode){
if($end - $start > 16)
$end = $start + 16;
$xarray = array_slice($bytesIn, $start, $end-$start);
$cpad = 16 - count($xarray);
while(count($xarray) < 16){
array_push($xarray, $cpad);
}
return $xarray;
} | [
"private",
"static",
"function",
"getPaddedBlock",
"(",
"$",
"bytesIn",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"end",
"-",
"$",
"start",
">",
"16",
")",
"$",
"end",
"=",
"$",
"start",
"+",
"16",
";",
"$",
"xarray",
"=",
"array_slice",
"(",
"$",
"bytesIn",
",",
"$",
"start",
",",
"$",
"end",
"-",
"$",
"start",
")",
";",
"$",
"cpad",
"=",
"16",
"-",
"count",
"(",
"$",
"xarray",
")",
";",
"while",
"(",
"count",
"(",
"$",
"xarray",
")",
"<",
"16",
")",
"{",
"array_push",
"(",
"$",
"xarray",
",",
"$",
"cpad",
")",
";",
"}",
"return",
"$",
"xarray",
";",
"}"
] | gets a properly padded block | [
"gets",
"a",
"properly",
"padded",
"block"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L529-L542 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.encrypt | public static function encrypt($bytesIn, $mode, $key, $size, $iv){
if(count($key)%$size)
{
throw new Exception('Key length does not match specified size.');
}
if(count($iv)%16)
{
throw new Exception('iv length must be 128 bits.');
}
// the AES input/output
$byteArray = array();
$input = array();
$output = array();
$ciphertext = array();
$cipherOut = array();
// char firstRound
$firstRound = true;
if ($bytesIn !== null)
{
for ($j = 0;$j < ceil(count($bytesIn)/16); $j++)
{
$start = $j*16;
$end = $j*16+16;
if($j*16+16 > count($bytesIn))
$end = count($bytesIn);
$byteArray = self::getPaddedBlock($bytesIn,$start,$end,$mode);
if ($mode == self::modeOfOperation_CFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($cipherOut, $ciphertext[$k]);
$input = $ciphertext;
}
else if ($mode == self::modeOfOperation_OFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($cipherOut, $ciphertext[$k]);
$input = $output;
}
else if ($mode == self::modeOfOperation_CBC)
{
for ($i = 0; $i < 16; $i++)
$input[$i] = $byteArray[$i] ^ (($firstRound) ? $iv[$i] : $ciphertext[$i]);
$firstRound = false;
$ciphertext = self::encryptBlock($input, $key, $size);
// always 16 bytes because of the padding for CBC
for($k = 0;$k < 16;$k++)
array_push($cipherOut, $ciphertext[$k]);
}
}
}
return array('mode' => $mode, 'originalsize' => count($bytesIn), 'cipher' => $cipherOut);
} | php | public static function encrypt($bytesIn, $mode, $key, $size, $iv){
if(count($key)%$size)
{
throw new Exception('Key length does not match specified size.');
}
if(count($iv)%16)
{
throw new Exception('iv length must be 128 bits.');
}
// the AES input/output
$byteArray = array();
$input = array();
$output = array();
$ciphertext = array();
$cipherOut = array();
// char firstRound
$firstRound = true;
if ($bytesIn !== null)
{
for ($j = 0;$j < ceil(count($bytesIn)/16); $j++)
{
$start = $j*16;
$end = $j*16+16;
if($j*16+16 > count($bytesIn))
$end = count($bytesIn);
$byteArray = self::getPaddedBlock($bytesIn,$start,$end,$mode);
if ($mode == self::modeOfOperation_CFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($cipherOut, $ciphertext[$k]);
$input = $ciphertext;
}
else if ($mode == self::modeOfOperation_OFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($cipherOut, $ciphertext[$k]);
$input = $output;
}
else if ($mode == self::modeOfOperation_CBC)
{
for ($i = 0; $i < 16; $i++)
$input[$i] = $byteArray[$i] ^ (($firstRound) ? $iv[$i] : $ciphertext[$i]);
$firstRound = false;
$ciphertext = self::encryptBlock($input, $key, $size);
// always 16 bytes because of the padding for CBC
for($k = 0;$k < 16;$k++)
array_push($cipherOut, $ciphertext[$k]);
}
}
}
return array('mode' => $mode, 'originalsize' => count($bytesIn), 'cipher' => $cipherOut);
} | [
"public",
"static",
"function",
"encrypt",
"(",
"$",
"bytesIn",
",",
"$",
"mode",
",",
"$",
"key",
",",
"$",
"size",
",",
"$",
"iv",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"key",
")",
"%",
"$",
"size",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Key length does not match specified size.'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"iv",
")",
"%",
"16",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'iv length must be 128 bits.'",
")",
";",
"}",
"// the AES input/output",
"$",
"byteArray",
"=",
"array",
"(",
")",
";",
"$",
"input",
"=",
"array",
"(",
")",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"ciphertext",
"=",
"array",
"(",
")",
";",
"$",
"cipherOut",
"=",
"array",
"(",
")",
";",
"// char firstRound",
"$",
"firstRound",
"=",
"true",
";",
"if",
"(",
"$",
"bytesIn",
"!==",
"null",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"ceil",
"(",
"count",
"(",
"$",
"bytesIn",
")",
"/",
"16",
")",
";",
"$",
"j",
"++",
")",
"{",
"$",
"start",
"=",
"$",
"j",
"*",
"16",
";",
"$",
"end",
"=",
"$",
"j",
"*",
"16",
"+",
"16",
";",
"if",
"(",
"$",
"j",
"*",
"16",
"+",
"16",
">",
"count",
"(",
"$",
"bytesIn",
")",
")",
"$",
"end",
"=",
"count",
"(",
"$",
"bytesIn",
")",
";",
"$",
"byteArray",
"=",
"self",
"::",
"getPaddedBlock",
"(",
"$",
"bytesIn",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_CFB",
")",
"{",
"if",
"(",
"$",
"firstRound",
")",
"{",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"iv",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"$",
"firstRound",
"=",
"false",
";",
"}",
"else",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"ciphertext",
"[",
"$",
"i",
"]",
"=",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"^",
"$",
"output",
"[",
"$",
"i",
"]",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"end",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"cipherOut",
",",
"$",
"ciphertext",
"[",
"$",
"k",
"]",
")",
";",
"$",
"input",
"=",
"$",
"ciphertext",
";",
"}",
"else",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_OFB",
")",
"{",
"if",
"(",
"$",
"firstRound",
")",
"{",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"iv",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"$",
"firstRound",
"=",
"false",
";",
"}",
"else",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"ciphertext",
"[",
"$",
"i",
"]",
"=",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"^",
"$",
"output",
"[",
"$",
"i",
"]",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"end",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"cipherOut",
",",
"$",
"ciphertext",
"[",
"$",
"k",
"]",
")",
";",
"$",
"input",
"=",
"$",
"output",
";",
"}",
"else",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_CBC",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"input",
"[",
"$",
"i",
"]",
"=",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"^",
"(",
"(",
"$",
"firstRound",
")",
"?",
"$",
"iv",
"[",
"$",
"i",
"]",
":",
"$",
"ciphertext",
"[",
"$",
"i",
"]",
")",
";",
"$",
"firstRound",
"=",
"false",
";",
"$",
"ciphertext",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"// always 16 bytes because of the padding for CBC",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"16",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"cipherOut",
",",
"$",
"ciphertext",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}",
"return",
"array",
"(",
"'mode'",
"=>",
"$",
"mode",
",",
"'originalsize'",
"=>",
"count",
"(",
"$",
"bytesIn",
")",
",",
"'cipher'",
"=>",
"$",
"cipherOut",
")",
";",
"}"
] | /*
Mode of Operation Encryption
bytesIn - Input String as array of bytes
mode - mode of type modeOfOperation
key - a number array of length 'size'
size - the bit length of the key
iv - the 128 bit number array Initialization Vector | [
"/",
"*",
"Mode",
"of",
"Operation",
"Encryption",
"bytesIn",
"-",
"Input",
"String",
"as",
"array",
"of",
"bytes",
"mode",
"-",
"mode",
"of",
"type",
"modeOfOperation",
"key",
"-",
"a",
"number",
"array",
"of",
"length",
"size",
"size",
"-",
"the",
"bit",
"length",
"of",
"the",
"key",
"iv",
"-",
"the",
"128",
"bit",
"number",
"array",
"Initialization",
"Vector"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L552-L621 |
Double-Opt-in/php-client-api | src/Security/SlowAES/AES.php | AES.decrypt | public static function decrypt($cipherIn,$originalsize,$mode,$key,$size,$iv)
{
if(count($key)%$size)
{
throw new Exception('Key length does not match specified size.');
return null;
}
if(count($iv)%16)
{
throw new Exception('iv length must be 128 bits.');
}
// the AES input/output
$ciphertext = array();
$input = array();
$output = array();
$byteArray = array();
$bytesOut = array();
// char firstRound
$firstRound = true;
if ($cipherIn !== null)
{
for ($j = 0;$j < ceil(count($cipherIn)/16); $j++)
{
$start = $j*16;
$end = $j*16+16;
if($j*16+16 > count($cipherIn))
$end = count($cipherIn);
$ciphertext = self::getPaddedBlock($cipherIn,$start,$end,$mode);
if ($mode == self::modeOfOperation_CFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $ciphertext;
}
else if ($mode == self::modeOfOperation_OFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $output;
}
else if($mode == self::modeOfOperation_CBC)
{
$output = self::decryptBlock($ciphertext, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = (($firstRound) ? $iv[$i] : $input[$i]) ^ $output[$i];
$firstRound = false;
if ($originalsize < $end)
for($k = 0;$k < $originalsize-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
else
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $ciphertext;
}
}
}
return $bytesOut;
} | php | public static function decrypt($cipherIn,$originalsize,$mode,$key,$size,$iv)
{
if(count($key)%$size)
{
throw new Exception('Key length does not match specified size.');
return null;
}
if(count($iv)%16)
{
throw new Exception('iv length must be 128 bits.');
}
// the AES input/output
$ciphertext = array();
$input = array();
$output = array();
$byteArray = array();
$bytesOut = array();
// char firstRound
$firstRound = true;
if ($cipherIn !== null)
{
for ($j = 0;$j < ceil(count($cipherIn)/16); $j++)
{
$start = $j*16;
$end = $j*16+16;
if($j*16+16 > count($cipherIn))
$end = count($cipherIn);
$ciphertext = self::getPaddedBlock($cipherIn,$start,$end,$mode);
if ($mode == self::modeOfOperation_CFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $ciphertext;
}
else if ($mode == self::modeOfOperation_OFB)
{
if ($firstRound)
{
$output = self::encryptBlock($iv, $key, $size);
$firstRound = false;
}
else
$output = self::encryptBlock($input, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $output;
}
else if($mode == self::modeOfOperation_CBC)
{
$output = self::decryptBlock($ciphertext, $key, $size);
for ($i = 0; $i < 16; $i++)
$byteArray[$i] = (($firstRound) ? $iv[$i] : $input[$i]) ^ $output[$i];
$firstRound = false;
if ($originalsize < $end)
for($k = 0;$k < $originalsize-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
else
for($k = 0;$k < $end-$start;$k++)
array_push($bytesOut, $byteArray[$k]);
$input = $ciphertext;
}
}
}
return $bytesOut;
} | [
"public",
"static",
"function",
"decrypt",
"(",
"$",
"cipherIn",
",",
"$",
"originalsize",
",",
"$",
"mode",
",",
"$",
"key",
",",
"$",
"size",
",",
"$",
"iv",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"key",
")",
"%",
"$",
"size",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Key length does not match specified size.'",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"iv",
")",
"%",
"16",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'iv length must be 128 bits.'",
")",
";",
"}",
"// the AES input/output",
"$",
"ciphertext",
"=",
"array",
"(",
")",
";",
"$",
"input",
"=",
"array",
"(",
")",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"byteArray",
"=",
"array",
"(",
")",
";",
"$",
"bytesOut",
"=",
"array",
"(",
")",
";",
"// char firstRound",
"$",
"firstRound",
"=",
"true",
";",
"if",
"(",
"$",
"cipherIn",
"!==",
"null",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"ceil",
"(",
"count",
"(",
"$",
"cipherIn",
")",
"/",
"16",
")",
";",
"$",
"j",
"++",
")",
"{",
"$",
"start",
"=",
"$",
"j",
"*",
"16",
";",
"$",
"end",
"=",
"$",
"j",
"*",
"16",
"+",
"16",
";",
"if",
"(",
"$",
"j",
"*",
"16",
"+",
"16",
">",
"count",
"(",
"$",
"cipherIn",
")",
")",
"$",
"end",
"=",
"count",
"(",
"$",
"cipherIn",
")",
";",
"$",
"ciphertext",
"=",
"self",
"::",
"getPaddedBlock",
"(",
"$",
"cipherIn",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_CFB",
")",
"{",
"if",
"(",
"$",
"firstRound",
")",
"{",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"iv",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"$",
"firstRound",
"=",
"false",
";",
"}",
"else",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"=",
"$",
"output",
"[",
"$",
"i",
"]",
"^",
"$",
"ciphertext",
"[",
"$",
"i",
"]",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"end",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"bytesOut",
",",
"$",
"byteArray",
"[",
"$",
"k",
"]",
")",
";",
"$",
"input",
"=",
"$",
"ciphertext",
";",
"}",
"else",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_OFB",
")",
"{",
"if",
"(",
"$",
"firstRound",
")",
"{",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"iv",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"$",
"firstRound",
"=",
"false",
";",
"}",
"else",
"$",
"output",
"=",
"self",
"::",
"encryptBlock",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"=",
"$",
"output",
"[",
"$",
"i",
"]",
"^",
"$",
"ciphertext",
"[",
"$",
"i",
"]",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"end",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"bytesOut",
",",
"$",
"byteArray",
"[",
"$",
"k",
"]",
")",
";",
"$",
"input",
"=",
"$",
"output",
";",
"}",
"else",
"if",
"(",
"$",
"mode",
"==",
"self",
"::",
"modeOfOperation_CBC",
")",
"{",
"$",
"output",
"=",
"self",
"::",
"decryptBlock",
"(",
"$",
"ciphertext",
",",
"$",
"key",
",",
"$",
"size",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"16",
";",
"$",
"i",
"++",
")",
"$",
"byteArray",
"[",
"$",
"i",
"]",
"=",
"(",
"(",
"$",
"firstRound",
")",
"?",
"$",
"iv",
"[",
"$",
"i",
"]",
":",
"$",
"input",
"[",
"$",
"i",
"]",
")",
"^",
"$",
"output",
"[",
"$",
"i",
"]",
";",
"$",
"firstRound",
"=",
"false",
";",
"if",
"(",
"$",
"originalsize",
"<",
"$",
"end",
")",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"originalsize",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"bytesOut",
",",
"$",
"byteArray",
"[",
"$",
"k",
"]",
")",
";",
"else",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"$",
"end",
"-",
"$",
"start",
";",
"$",
"k",
"++",
")",
"array_push",
"(",
"$",
"bytesOut",
",",
"$",
"byteArray",
"[",
"$",
"k",
"]",
")",
";",
"$",
"input",
"=",
"$",
"ciphertext",
";",
"}",
"}",
"}",
"return",
"$",
"bytesOut",
";",
"}"
] | /*
Mode of Operation Decryption
cipherIn - Encrypted String as array of bytes
originalsize - The unencrypted string length - required for CBC
mode - mode of type modeOfOperation
key - a number array of length 'size'
size - the bit length of the key
iv - the 128 bit number array Initialization Vector | [
"/",
"*",
"Mode",
"of",
"Operation",
"Decryption",
"cipherIn",
"-",
"Encrypted",
"String",
"as",
"array",
"of",
"bytes",
"originalsize",
"-",
"The",
"unencrypted",
"string",
"length",
"-",
"required",
"for",
"CBC",
"mode",
"-",
"mode",
"of",
"type",
"modeOfOperation",
"key",
"-",
"a",
"number",
"array",
"of",
"length",
"size",
"size",
"-",
"the",
"bit",
"length",
"of",
"the",
"key",
"iv",
"-",
"the",
"128",
"bit",
"number",
"array",
"Initialization",
"Vector"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L632-L707 |
okitcom/ok-lib-php | src/Service/Cash.php | Cash.refund | public function refund($guid, Amount $refundAmount) {
return new Transaction(
$this->client->post('transactions/' . $guid . '/refunds', ["amount" => $refundAmount])
);
} | php | public function refund($guid, Amount $refundAmount) {
return new Transaction(
$this->client->post('transactions/' . $guid . '/refunds', ["amount" => $refundAmount])
);
} | [
"public",
"function",
"refund",
"(",
"$",
"guid",
",",
"Amount",
"$",
"refundAmount",
")",
"{",
"return",
"new",
"Transaction",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"'transactions/'",
".",
"$",
"guid",
".",
"'/refunds'",
",",
"[",
"\"amount\"",
"=>",
"$",
"refundAmount",
"]",
")",
")",
";",
"}"
] | Refunds a previously initiated and closed and captured transaction.
@param $guid string identifier of transaction
@param $refundAmount Amount amount to refund in cents
@return string
@throws NetworkException | [
"Refunds",
"a",
"previously",
"initiated",
"and",
"closed",
"and",
"captured",
"transaction",
"."
] | train | https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/Cash.php#L101-L105 |
ClanCats/Core | src/bundles/Database/Model/Relation/HasOne.php | Model_Relation_HasOne.prepare_query | protected function prepare_query()
{
$this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} )
->limit( 1 );
} | php | protected function prepare_query()
{
$this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} )
->limit( 1 );
} | [
"protected",
"function",
"prepare_query",
"(",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"$",
"this",
"->",
"foreign_key",
",",
"$",
"this",
"->",
"local_model",
"->",
"{",
"$",
"this",
"->",
"local_key",
"}",
")",
"->",
"limit",
"(",
"1",
")",
";",
"}"
] | Prepare the query object
@return void | [
"Prepare",
"the",
"query",
"object"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model/Relation/HasOne.php#L19-L23 |
alanpich/slender | core-modules/event-manager/src/EventManager.php | EventManager.hook | public function hook($event, callable $callback, $priority = 10)
{
$this->app->hook($event, $callback, $priority);
} | php | public function hook($event, callable $callback, $priority = 10)
{
$this->app->hook($event, $callback, $priority);
} | [
"public",
"function",
"hook",
"(",
"$",
"event",
",",
"callable",
"$",
"callback",
",",
"$",
"priority",
"=",
"10",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"hook",
"(",
"$",
"event",
",",
"$",
"callback",
",",
"$",
"priority",
")",
";",
"}"
] | Hook an event
@param string $event Event/Hook name
@param callable $callback Event handler
@param int $priority 0 = high, 10 = low | [
"Hook",
"an",
"event"
] | train | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/core-modules/event-manager/src/EventManager.php#L65-L68 |
alanpich/slender | core-modules/event-manager/src/EventManager.php | EventManager.applyChain | public function applyChain($name, $hookArg = null)
{
$hooks = $this->app->getHooks();
if (!isset($hooks[$name])) {
$hooks[$name] = array(array());
}
if (!empty($hooks[$name])) {
// Sort by priority, low to high, if there's more than one priority
if (count($hooks[$name]) > 1) {
ksort($hooks[$name]);
}
foreach ($hooks[$name] as $priority) {
if (!empty($priority)) {
foreach ($priority as $callable) {
$value = call_user_func($callable, $hookArg);
if ($value !== null) {
return $value;
}
}
}
}
}
} | php | public function applyChain($name, $hookArg = null)
{
$hooks = $this->app->getHooks();
if (!isset($hooks[$name])) {
$hooks[$name] = array(array());
}
if (!empty($hooks[$name])) {
// Sort by priority, low to high, if there's more than one priority
if (count($hooks[$name]) > 1) {
ksort($hooks[$name]);
}
foreach ($hooks[$name] as $priority) {
if (!empty($priority)) {
foreach ($priority as $callable) {
$value = call_user_func($callable, $hookArg);
if ($value !== null) {
return $value;
}
}
}
}
}
} | [
"public",
"function",
"applyChain",
"(",
"$",
"name",
",",
"$",
"hookArg",
"=",
"null",
")",
"{",
"$",
"hooks",
"=",
"$",
"this",
"->",
"app",
"->",
"getHooks",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"hooks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"hooks",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"array",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"hooks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// Sort by priority, low to high, if there's more than one priority",
"if",
"(",
"count",
"(",
"$",
"hooks",
"[",
"$",
"name",
"]",
")",
">",
"1",
")",
"{",
"ksort",
"(",
"$",
"hooks",
"[",
"$",
"name",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"hooks",
"[",
"$",
"name",
"]",
"as",
"$",
"priority",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"priority",
")",
")",
"{",
"foreach",
"(",
"$",
"priority",
"as",
"$",
"callable",
")",
"{",
"$",
"value",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"hookArg",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Trigger a chained hook
- The first callback to return a non-null value
will be returned
@param string $name the hook name
@param mixed $hookArg (Optional) Argument for hooked functions
@return mixed|void | [
"Trigger",
"a",
"chained",
"hook",
"-",
"The",
"first",
"callback",
"to",
"return",
"a",
"non",
"-",
"null",
"value",
"will",
"be",
"returned"
] | train | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/core-modules/event-manager/src/EventManager.php#L104-L127 |
yuncms/framework | src/console/controllers/OAuth2Controller.php | OAuth2Controller.actionClear | public function actionClear()
{
OAuth2AuthorizationCode::deleteAll(['<', 'expires', time()]);
OAuth2RefreshToken::deleteAll(['<', 'expires', time()]);
OAuth2AccessToken::deleteAll(['<', 'expires', time()]);
} | php | public function actionClear()
{
OAuth2AuthorizationCode::deleteAll(['<', 'expires', time()]);
OAuth2RefreshToken::deleteAll(['<', 'expires', time()]);
OAuth2AccessToken::deleteAll(['<', 'expires', time()]);
} | [
"public",
"function",
"actionClear",
"(",
")",
"{",
"OAuth2AuthorizationCode",
"::",
"deleteAll",
"(",
"[",
"'<'",
",",
"'expires'",
",",
"time",
"(",
")",
"]",
")",
";",
"OAuth2RefreshToken",
"::",
"deleteAll",
"(",
"[",
"'<'",
",",
"'expires'",
",",
"time",
"(",
")",
"]",
")",
";",
"OAuth2AccessToken",
"::",
"deleteAll",
"(",
"[",
"'<'",
",",
"'expires'",
",",
"time",
"(",
")",
"]",
")",
";",
"}"
] | Clean up expired token | [
"Clean",
"up",
"expired",
"token"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/OAuth2Controller.php#L23-L28 |
sparwelt/imgix-lib | src/Components/AttributeGenerator.php | AttributeGenerator.generateAttributeValue | public function generateAttributeValue($sourceImageUrl, $filters = [])
{
// ['1x' => ['w' => 123, 'h' => 200], '2x' = > [..]]
if (Utils::isMatrix($filters)) {
$srcset = [];
foreach ($filters as $format => $formatFilters) {
$srcset[] = sprintf(
'%s %s',
$this->urlGenerator->generateUrl($sourceImageUrl, $formatFilters),
$format
);
}
return implode(', ', $srcset);
}
// ['w' => 123, 'h' => 200]
if (is_array($filters)) {
return $this->urlGenerator->generateUrl($sourceImageUrl, $filters);
}
// '(min-width: 36em) 33.3vw, 100vw' or 'auto' (e.g. 'sizes')
if (is_scalar($filters)) {
return $filters;
}
throw new ConfigurationException('Filters should be either array or scalar');
} | php | public function generateAttributeValue($sourceImageUrl, $filters = [])
{
// ['1x' => ['w' => 123, 'h' => 200], '2x' = > [..]]
if (Utils::isMatrix($filters)) {
$srcset = [];
foreach ($filters as $format => $formatFilters) {
$srcset[] = sprintf(
'%s %s',
$this->urlGenerator->generateUrl($sourceImageUrl, $formatFilters),
$format
);
}
return implode(', ', $srcset);
}
// ['w' => 123, 'h' => 200]
if (is_array($filters)) {
return $this->urlGenerator->generateUrl($sourceImageUrl, $filters);
}
// '(min-width: 36em) 33.3vw, 100vw' or 'auto' (e.g. 'sizes')
if (is_scalar($filters)) {
return $filters;
}
throw new ConfigurationException('Filters should be either array or scalar');
} | [
"public",
"function",
"generateAttributeValue",
"(",
"$",
"sourceImageUrl",
",",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"// ['1x' => ['w' => 123, 'h' => 200], '2x' = > [..]]",
"if",
"(",
"Utils",
"::",
"isMatrix",
"(",
"$",
"filters",
")",
")",
"{",
"$",
"srcset",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"format",
"=>",
"$",
"formatFilters",
")",
"{",
"$",
"srcset",
"[",
"]",
"=",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"this",
"->",
"urlGenerator",
"->",
"generateUrl",
"(",
"$",
"sourceImageUrl",
",",
"$",
"formatFilters",
")",
",",
"$",
"format",
")",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"srcset",
")",
";",
"}",
"// ['w' => 123, 'h' => 200]",
"if",
"(",
"is_array",
"(",
"$",
"filters",
")",
")",
"{",
"return",
"$",
"this",
"->",
"urlGenerator",
"->",
"generateUrl",
"(",
"$",
"sourceImageUrl",
",",
"$",
"filters",
")",
";",
"}",
"// '(min-width: 36em) 33.3vw, 100vw' or 'auto' (e.g. 'sizes')",
"if",
"(",
"is_scalar",
"(",
"$",
"filters",
")",
")",
"{",
"return",
"$",
"filters",
";",
"}",
"throw",
"new",
"ConfigurationException",
"(",
"'Filters should be either array or scalar'",
")",
";",
"}"
] | @param string $sourceImageUrl
@param array|string $filters
@return string | [
"@param",
"string",
"$sourceImageUrl",
"@param",
"array|string",
"$filters"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/AttributeGenerator.php#L35-L62 |
ClanCats/Core | src/classes/CCShipyard/Dbmodel.php | CCShipyard_Dbmodel.output | public function output()
{
$shema = \DB::fetch( "DESCRIBE {$this->table};", array(), null, 'assoc' );
if ( empty( $shema ) )
{
throw new CCException( 'CCShipyard - The given database table is invalid or does not exist.' );
}
$class = \CCShipyard::create( 'class', $this->name, "\\DB\\Model" );
$class->add( 'property', '_table', 'protected static', $this->table, 'The database table name' );
// timestamps
if ( $this->timestamps )
{
$class->add( 'line', 2 );
$class->add( 'property', '_timestamps', 'protected static', true, 'Allow automatic timestamps' );
}
// shema
$class->add( 'line', 2 );
// define the internal types
$internal_types = array( 'bool', 'int', 'float', 'double', 'string' );
$match_types = array(
// int
'tinyint' => 'int',
// string
'text' => 'string',
'varchar' => 'string',
);
foreach( $shema as $item )
{
$default = $item['Default'];
$field = $item['Field'];
if ( empty( $default ) )
{
$type = \CCStr::cut( $item['Type'], '(' );
if ( array_key_exists( $type, $match_types ) )
{
$type = $match_types[$type];
}
elseif ( !in_array( $type, $internal_types ) )
{
$type = null;
}
// The primary key should not contain a default value
if ( $item['Key'] == 'PRI' )
{
$type = null;
}
// specialcase tinyint 1 assumed as boolean
elseif ( $item['Type'] == 'tinyint(1)' )
{
$type = 'bool';
}
if ( $type !== null )
{
settype( $default, $type );
}
}
$buffer = "\t'$field'";
if ( !is_null( $type ) )
{
$buffer .= " => array( '".$type."'";
if ( !is_null( $default ) )
{
$buffer .= ", ".var_export( $default, true )." )";
}
}
$props[] = $buffer;
}
$class->add( 'property', '_defaults', 'protected static', "array(\n".implode( ",\n", $props )."\n)", 'The '.$class.' default properties', false );
return $class->output();
} | php | public function output()
{
$shema = \DB::fetch( "DESCRIBE {$this->table};", array(), null, 'assoc' );
if ( empty( $shema ) )
{
throw new CCException( 'CCShipyard - The given database table is invalid or does not exist.' );
}
$class = \CCShipyard::create( 'class', $this->name, "\\DB\\Model" );
$class->add( 'property', '_table', 'protected static', $this->table, 'The database table name' );
// timestamps
if ( $this->timestamps )
{
$class->add( 'line', 2 );
$class->add( 'property', '_timestamps', 'protected static', true, 'Allow automatic timestamps' );
}
// shema
$class->add( 'line', 2 );
// define the internal types
$internal_types = array( 'bool', 'int', 'float', 'double', 'string' );
$match_types = array(
// int
'tinyint' => 'int',
// string
'text' => 'string',
'varchar' => 'string',
);
foreach( $shema as $item )
{
$default = $item['Default'];
$field = $item['Field'];
if ( empty( $default ) )
{
$type = \CCStr::cut( $item['Type'], '(' );
if ( array_key_exists( $type, $match_types ) )
{
$type = $match_types[$type];
}
elseif ( !in_array( $type, $internal_types ) )
{
$type = null;
}
// The primary key should not contain a default value
if ( $item['Key'] == 'PRI' )
{
$type = null;
}
// specialcase tinyint 1 assumed as boolean
elseif ( $item['Type'] == 'tinyint(1)' )
{
$type = 'bool';
}
if ( $type !== null )
{
settype( $default, $type );
}
}
$buffer = "\t'$field'";
if ( !is_null( $type ) )
{
$buffer .= " => array( '".$type."'";
if ( !is_null( $default ) )
{
$buffer .= ", ".var_export( $default, true )." )";
}
}
$props[] = $buffer;
}
$class->add( 'property', '_defaults', 'protected static', "array(\n".implode( ",\n", $props )."\n)", 'The '.$class.' default properties', false );
return $class->output();
} | [
"public",
"function",
"output",
"(",
")",
"{",
"$",
"shema",
"=",
"\\",
"DB",
"::",
"fetch",
"(",
"\"DESCRIBE {$this->table};\"",
",",
"array",
"(",
")",
",",
"null",
",",
"'assoc'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"shema",
")",
")",
"{",
"throw",
"new",
"CCException",
"(",
"'CCShipyard - The given database table is invalid or does not exist.'",
")",
";",
"}",
"$",
"class",
"=",
"\\",
"CCShipyard",
"::",
"create",
"(",
"'class'",
",",
"$",
"this",
"->",
"name",
",",
"\"\\\\DB\\\\Model\"",
")",
";",
"$",
"class",
"->",
"add",
"(",
"'property'",
",",
"'_table'",
",",
"'protected static'",
",",
"$",
"this",
"->",
"table",
",",
"'The database table name'",
")",
";",
"// timestamps",
"if",
"(",
"$",
"this",
"->",
"timestamps",
")",
"{",
"$",
"class",
"->",
"add",
"(",
"'line'",
",",
"2",
")",
";",
"$",
"class",
"->",
"add",
"(",
"'property'",
",",
"'_timestamps'",
",",
"'protected static'",
",",
"true",
",",
"'Allow automatic timestamps'",
")",
";",
"}",
"// shema",
"$",
"class",
"->",
"add",
"(",
"'line'",
",",
"2",
")",
";",
"// define the internal types",
"$",
"internal_types",
"=",
"array",
"(",
"'bool'",
",",
"'int'",
",",
"'float'",
",",
"'double'",
",",
"'string'",
")",
";",
"$",
"match_types",
"=",
"array",
"(",
"// int",
"'tinyint'",
"=>",
"'int'",
",",
"// string",
"'text'",
"=>",
"'string'",
",",
"'varchar'",
"=>",
"'string'",
",",
")",
";",
"foreach",
"(",
"$",
"shema",
"as",
"$",
"item",
")",
"{",
"$",
"default",
"=",
"$",
"item",
"[",
"'Default'",
"]",
";",
"$",
"field",
"=",
"$",
"item",
"[",
"'Field'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"$",
"type",
"=",
"\\",
"CCStr",
"::",
"cut",
"(",
"$",
"item",
"[",
"'Type'",
"]",
",",
"'('",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"match_types",
")",
")",
"{",
"$",
"type",
"=",
"$",
"match_types",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"$",
"internal_types",
")",
")",
"{",
"$",
"type",
"=",
"null",
";",
"}",
"// The primary key should not contain a default value",
"if",
"(",
"$",
"item",
"[",
"'Key'",
"]",
"==",
"'PRI'",
")",
"{",
"$",
"type",
"=",
"null",
";",
"}",
"// specialcase tinyint 1 assumed as boolean",
"elseif",
"(",
"$",
"item",
"[",
"'Type'",
"]",
"==",
"'tinyint(1)'",
")",
"{",
"$",
"type",
"=",
"'bool'",
";",
"}",
"if",
"(",
"$",
"type",
"!==",
"null",
")",
"{",
"settype",
"(",
"$",
"default",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"buffer",
"=",
"\"\\t'$field'\"",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"$",
"buffer",
".=",
"\" => array( '\"",
".",
"$",
"type",
".",
"\"'\"",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"default",
")",
")",
"{",
"$",
"buffer",
".=",
"\", \"",
".",
"var_export",
"(",
"$",
"default",
",",
"true",
")",
".",
"\" )\"",
";",
"}",
"}",
"$",
"props",
"[",
"]",
"=",
"$",
"buffer",
";",
"}",
"$",
"class",
"->",
"add",
"(",
"'property'",
",",
"'_defaults'",
",",
"'protected static'",
",",
"\"array(\\n\"",
".",
"implode",
"(",
"\",\\n\"",
",",
"$",
"props",
")",
".",
"\"\\n)\"",
",",
"'The '",
".",
"$",
"class",
".",
"' default properties'",
",",
"false",
")",
";",
"return",
"$",
"class",
"->",
"output",
"(",
")",
";",
"}"
] | Get the current builder output
@return string | [
"Get",
"the",
"current",
"builder",
"output"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCShipyard/Dbmodel.php#L50-L139 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.