repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
iRipVanWinkle/codeception-migration | src/Migration.php | Migration.runMigrationByPaths | protected function runMigrationByPaths($migrationPaths, $command)
{
$app = $this->mockApplication();
$this->validateMigrationPaths($migrationPaths);
/* @todo: since version 2.0.12 you may also specify an array of migration paths. */
foreach ($migrationPaths as $migrationPath) {
$migrateController = $this->buildMigration($app);
$migrateController->migrationPath = $migrationPath;
$this->runMigration($migrateController, $command);
}
$this->destroyApplication();
} | php | protected function runMigrationByPaths($migrationPaths, $command)
{
$app = $this->mockApplication();
$this->validateMigrationPaths($migrationPaths);
/* @todo: since version 2.0.12 you may also specify an array of migration paths. */
foreach ($migrationPaths as $migrationPath) {
$migrateController = $this->buildMigration($app);
$migrateController->migrationPath = $migrationPath;
$this->runMigration($migrateController, $command);
}
$this->destroyApplication();
} | [
"protected",
"function",
"runMigrationByPaths",
"(",
"$",
"migrationPaths",
",",
"$",
"command",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"mockApplication",
"(",
")",
";",
"$",
"this",
"->",
"validateMigrationPaths",
"(",
"$",
"migrationPaths",
")",
";",
"/* @todo: since version 2.0.12 you may also specify an array of migration paths. */",
"foreach",
"(",
"$",
"migrationPaths",
"as",
"$",
"migrationPath",
")",
"{",
"$",
"migrateController",
"=",
"$",
"this",
"->",
"buildMigration",
"(",
"$",
"app",
")",
";",
"$",
"migrateController",
"->",
"migrationPath",
"=",
"$",
"migrationPath",
";",
"$",
"this",
"->",
"runMigration",
"(",
"$",
"migrateController",
",",
"$",
"command",
")",
";",
"}",
"$",
"this",
"->",
"destroyApplication",
"(",
")",
";",
"}"
] | Run migration by paths
@param array $migrationPaths
@param $command
@throws ExtensionException | [
"Run",
"migration",
"by",
"paths"
] | 1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0 | https://github.com/iRipVanWinkle/codeception-migration/blob/1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0/src/Migration.php#L100-L115 | train |
iRipVanWinkle/codeception-migration | src/Migration.php | Migration.validateMigrationPaths | protected function validateMigrationPaths($migrationPaths)
{
foreach ($migrationPaths as $migrationPath) {
$path = \Yii::getAlias($migrationPath, false);
if ($path === false) {
throw new ExtensionException(
__CLASS__,
"Invalid path alias: $migrationPath"
);
}
if (!file_exists($path)) {
throw new ExtensionException(
__CLASS__,
"The migration path does not exist: " . realpath($this->getRootDir() . $path)
);
}
}
} | php | protected function validateMigrationPaths($migrationPaths)
{
foreach ($migrationPaths as $migrationPath) {
$path = \Yii::getAlias($migrationPath, false);
if ($path === false) {
throw new ExtensionException(
__CLASS__,
"Invalid path alias: $migrationPath"
);
}
if (!file_exists($path)) {
throw new ExtensionException(
__CLASS__,
"The migration path does not exist: " . realpath($this->getRootDir() . $path)
);
}
}
} | [
"protected",
"function",
"validateMigrationPaths",
"(",
"$",
"migrationPaths",
")",
"{",
"foreach",
"(",
"$",
"migrationPaths",
"as",
"$",
"migrationPath",
")",
"{",
"$",
"path",
"=",
"\\",
"Yii",
"::",
"getAlias",
"(",
"$",
"migrationPath",
",",
"false",
")",
";",
"if",
"(",
"$",
"path",
"===",
"false",
")",
"{",
"throw",
"new",
"ExtensionException",
"(",
"__CLASS__",
",",
"\"Invalid path alias: $migrationPath\"",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"ExtensionException",
"(",
"__CLASS__",
",",
"\"The migration path does not exist: \"",
".",
"realpath",
"(",
"$",
"this",
"->",
"getRootDir",
"(",
")",
".",
"$",
"path",
")",
")",
";",
"}",
"}",
"}"
] | Validate Migration Path
@param string $migrationPath
@throws ExtensionException | [
"Validate",
"Migration",
"Path"
] | 1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0 | https://github.com/iRipVanWinkle/codeception-migration/blob/1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0/src/Migration.php#L122-L140 | train |
iRipVanWinkle/codeception-migration | src/Migration.php | Migration.runMigrationByNamespaces | protected function runMigrationByNamespaces($migrationNamespaces, $command)
{
$app = $this->mockApplication();
$migrateController = $this->buildMigration($app);
$migrateController->migrationNamespaces = $migrationNamespaces;
$this->runMigration($migrateController, $command);
$this->destroyApplication();
} | php | protected function runMigrationByNamespaces($migrationNamespaces, $command)
{
$app = $this->mockApplication();
$migrateController = $this->buildMigration($app);
$migrateController->migrationNamespaces = $migrationNamespaces;
$this->runMigration($migrateController, $command);
$this->destroyApplication();
} | [
"protected",
"function",
"runMigrationByNamespaces",
"(",
"$",
"migrationNamespaces",
",",
"$",
"command",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"mockApplication",
"(",
")",
";",
"$",
"migrateController",
"=",
"$",
"this",
"->",
"buildMigration",
"(",
"$",
"app",
")",
";",
"$",
"migrateController",
"->",
"migrationNamespaces",
"=",
"$",
"migrationNamespaces",
";",
"$",
"this",
"->",
"runMigration",
"(",
"$",
"migrateController",
",",
"$",
"command",
")",
";",
"$",
"this",
"->",
"destroyApplication",
"(",
")",
";",
"}"
] | Run migration by namespaces
@param array $migrationNamespaces
@param string $command either `up` or `down` | [
"Run",
"migration",
"by",
"namespaces"
] | 1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0 | https://github.com/iRipVanWinkle/codeception-migration/blob/1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0/src/Migration.php#L147-L157 | train |
iRipVanWinkle/codeception-migration | src/Migration.php | Migration.runMigrationByApplication | protected function runMigrationByApplication($command)
{
$app = $this->mockApplication();
list($migrateController, $route) = $app->createController('migrate');
if ($migrateController === null) {
throw new ExtensionException(
__CLASS__,
"At least one of `migrationPath` or `migrationNamespaces` should be specified.\nOr describe migrations in your app config."
);
}
if ($migrateController->interactive) {
$this->writeln('Cannot run the migrate interactively, the interaction was disabled.');
$migrateController->interactive = false;
}
$this->runMigration($migrateController, $command);
$this->destroyApplication();
} | php | protected function runMigrationByApplication($command)
{
$app = $this->mockApplication();
list($migrateController, $route) = $app->createController('migrate');
if ($migrateController === null) {
throw new ExtensionException(
__CLASS__,
"At least one of `migrationPath` or `migrationNamespaces` should be specified.\nOr describe migrations in your app config."
);
}
if ($migrateController->interactive) {
$this->writeln('Cannot run the migrate interactively, the interaction was disabled.');
$migrateController->interactive = false;
}
$this->runMigration($migrateController, $command);
$this->destroyApplication();
} | [
"protected",
"function",
"runMigrationByApplication",
"(",
"$",
"command",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"mockApplication",
"(",
")",
";",
"list",
"(",
"$",
"migrateController",
",",
"$",
"route",
")",
"=",
"$",
"app",
"->",
"createController",
"(",
"'migrate'",
")",
";",
"if",
"(",
"$",
"migrateController",
"===",
"null",
")",
"{",
"throw",
"new",
"ExtensionException",
"(",
"__CLASS__",
",",
"\"At least one of `migrationPath` or `migrationNamespaces` should be specified.\\nOr describe migrations in your app config.\"",
")",
";",
"}",
"if",
"(",
"$",
"migrateController",
"->",
"interactive",
")",
"{",
"$",
"this",
"->",
"writeln",
"(",
"'Cannot run the migrate interactively, the interaction was disabled.'",
")",
";",
"$",
"migrateController",
"->",
"interactive",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"runMigration",
"(",
"$",
"migrateController",
",",
"$",
"command",
")",
";",
"$",
"this",
"->",
"destroyApplication",
"(",
")",
";",
"}"
] | Run migration from app config
@param string $command either `up` or `down` | [
"Run",
"migration",
"from",
"app",
"config"
] | 1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0 | https://github.com/iRipVanWinkle/codeception-migration/blob/1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0/src/Migration.php#L163-L184 | train |
iRipVanWinkle/codeception-migration | src/Migration.php | Migration.mockApplication | protected function mockApplication()
{
$entryUrl = $this->config['entryUrl'];
$entryFile = $this->config['entryScript'] ?: basename($entryUrl);
$entryScript = $this->config['entryScript'] ?: parse_url($entryUrl, PHP_URL_PATH);
$this->client = new Yii2Connector();
$this->client->defaultServerVars = [
'SCRIPT_FILENAME' => $entryFile,
'SCRIPT_NAME' => $entryScript,
'SERVER_NAME' => parse_url($entryUrl, PHP_URL_HOST),
'SERVER_PORT' => parse_url($entryUrl, PHP_URL_PORT) ?: '80',
];
$this->client->defaultServerVars['HTTPS'] = parse_url($entryUrl, PHP_URL_SCHEME) === 'https';
$this->client->restoreServerVars();
$this->client->configFile = $this->getRootDir() . $this->config['configFile'];
return $this->client->getApplication();
} | php | protected function mockApplication()
{
$entryUrl = $this->config['entryUrl'];
$entryFile = $this->config['entryScript'] ?: basename($entryUrl);
$entryScript = $this->config['entryScript'] ?: parse_url($entryUrl, PHP_URL_PATH);
$this->client = new Yii2Connector();
$this->client->defaultServerVars = [
'SCRIPT_FILENAME' => $entryFile,
'SCRIPT_NAME' => $entryScript,
'SERVER_NAME' => parse_url($entryUrl, PHP_URL_HOST),
'SERVER_PORT' => parse_url($entryUrl, PHP_URL_PORT) ?: '80',
];
$this->client->defaultServerVars['HTTPS'] = parse_url($entryUrl, PHP_URL_SCHEME) === 'https';
$this->client->restoreServerVars();
$this->client->configFile = $this->getRootDir() . $this->config['configFile'];
return $this->client->getApplication();
} | [
"protected",
"function",
"mockApplication",
"(",
")",
"{",
"$",
"entryUrl",
"=",
"$",
"this",
"->",
"config",
"[",
"'entryUrl'",
"]",
";",
"$",
"entryFile",
"=",
"$",
"this",
"->",
"config",
"[",
"'entryScript'",
"]",
"?",
":",
"basename",
"(",
"$",
"entryUrl",
")",
";",
"$",
"entryScript",
"=",
"$",
"this",
"->",
"config",
"[",
"'entryScript'",
"]",
"?",
":",
"parse_url",
"(",
"$",
"entryUrl",
",",
"PHP_URL_PATH",
")",
";",
"$",
"this",
"->",
"client",
"=",
"new",
"Yii2Connector",
"(",
")",
";",
"$",
"this",
"->",
"client",
"->",
"defaultServerVars",
"=",
"[",
"'SCRIPT_FILENAME'",
"=>",
"$",
"entryFile",
",",
"'SCRIPT_NAME'",
"=>",
"$",
"entryScript",
",",
"'SERVER_NAME'",
"=>",
"parse_url",
"(",
"$",
"entryUrl",
",",
"PHP_URL_HOST",
")",
",",
"'SERVER_PORT'",
"=>",
"parse_url",
"(",
"$",
"entryUrl",
",",
"PHP_URL_PORT",
")",
"?",
":",
"'80'",
",",
"]",
";",
"$",
"this",
"->",
"client",
"->",
"defaultServerVars",
"[",
"'HTTPS'",
"]",
"=",
"parse_url",
"(",
"$",
"entryUrl",
",",
"PHP_URL_SCHEME",
")",
"===",
"'https'",
";",
"$",
"this",
"->",
"client",
"->",
"restoreServerVars",
"(",
")",
";",
"$",
"this",
"->",
"client",
"->",
"configFile",
"=",
"$",
"this",
"->",
"getRootDir",
"(",
")",
".",
"$",
"this",
"->",
"config",
"[",
"'configFile'",
"]",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"getApplication",
"(",
")",
";",
"}"
] | Mocks up the application instance.
@return \yii\web\Application|\yii\console\Application the application instance
@throws InvalidConfigException if the application configuration is invalid | [
"Mocks",
"up",
"the",
"application",
"instance",
"."
] | 1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0 | https://github.com/iRipVanWinkle/codeception-migration/blob/1cc0bf4167ec9b0cf6590b1b687570b323d3f5d0/src/Migration.php#L222-L239 | train |
agentmedia/phine-core | src/Core/Modules/Backend/MemberForm.php | MemberForm.AddEMailField | private function AddEMailField()
{
$name = 'EMail';
$this->AddField(Input::Text($name, $this->member->GetEMail()));
$this->SetRequired($name);
$this->AddValidator($name, PhpFilter::EMail());
$this->AddValidator($name, DatabaseCount::UniqueField($this->member, $name));
} | php | private function AddEMailField()
{
$name = 'EMail';
$this->AddField(Input::Text($name, $this->member->GetEMail()));
$this->SetRequired($name);
$this->AddValidator($name, PhpFilter::EMail());
$this->AddValidator($name, DatabaseCount::UniqueField($this->member, $name));
} | [
"private",
"function",
"AddEMailField",
"(",
")",
"{",
"$",
"name",
"=",
"'EMail'",
";",
"$",
"this",
"->",
"AddField",
"(",
"Input",
"::",
"Text",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"member",
"->",
"GetEMail",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"SetRequired",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"AddValidator",
"(",
"$",
"name",
",",
"PhpFilter",
"::",
"EMail",
"(",
")",
")",
";",
"$",
"this",
"->",
"AddValidator",
"(",
"$",
"name",
",",
"DatabaseCount",
"::",
"UniqueField",
"(",
"$",
"this",
"->",
"member",
",",
"$",
"name",
")",
")",
";",
"}"
] | Adds the email field to the form | [
"Adds",
"the",
"email",
"field",
"to",
"the",
"form"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MemberForm.php#L67-L74 | train |
agentmedia/phine-core | src/Core/Modules/Backend/MemberForm.php | MemberForm.AddPasswordField | private function AddPasswordField()
{
$name = 'Password';
$this->AddField(Input::Password($name));
if (!$this->member->Exists())
{
$this->SetRequired($name);
}
$this->AddValidator($name, StringLength::MinLength(6));
$this->SetTransAttribute($name, 'placeholder');
} | php | private function AddPasswordField()
{
$name = 'Password';
$this->AddField(Input::Password($name));
if (!$this->member->Exists())
{
$this->SetRequired($name);
}
$this->AddValidator($name, StringLength::MinLength(6));
$this->SetTransAttribute($name, 'placeholder');
} | [
"private",
"function",
"AddPasswordField",
"(",
")",
"{",
"$",
"name",
"=",
"'Password'",
";",
"$",
"this",
"->",
"AddField",
"(",
"Input",
"::",
"Password",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"member",
"->",
"Exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SetRequired",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"AddValidator",
"(",
"$",
"name",
",",
"StringLength",
"::",
"MinLength",
"(",
"6",
")",
")",
";",
"$",
"this",
"->",
"SetTransAttribute",
"(",
"$",
"name",
",",
"'placeholder'",
")",
";",
"}"
] | Adds the password field to the form | [
"Adds",
"the",
"password",
"field",
"to",
"the",
"form"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MemberForm.php#L79-L90 | train |
agentmedia/phine-core | src/Core/Modules/Backend/MemberForm.php | MemberForm.OnSuccess | protected function OnSuccess()
{
$action = $this->member->Exists() ? Action::Update() : Action::Create();
$this->member->SetName($this->Value('Name'));
$this->member->SetEMail($this->Value('EMail'));
$this->SetPassword();
$this->member->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportMemberAction($thos->member, $action);
if ($this->groupsExist && $this->CanAssignGroup())
{
$this->SaveGroups();
}
Response::Redirect(BackendRouter::ModuleUrl(new MemberList()));
} | php | protected function OnSuccess()
{
$action = $this->member->Exists() ? Action::Update() : Action::Create();
$this->member->SetName($this->Value('Name'));
$this->member->SetEMail($this->Value('EMail'));
$this->SetPassword();
$this->member->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportMemberAction($thos->member, $action);
if ($this->groupsExist && $this->CanAssignGroup())
{
$this->SaveGroups();
}
Response::Redirect(BackendRouter::ModuleUrl(new MemberList()));
} | [
"protected",
"function",
"OnSuccess",
"(",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"member",
"->",
"Exists",
"(",
")",
"?",
"Action",
"::",
"Update",
"(",
")",
":",
"Action",
"::",
"Create",
"(",
")",
";",
"$",
"this",
"->",
"member",
"->",
"SetName",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Name'",
")",
")",
";",
"$",
"this",
"->",
"member",
"->",
"SetEMail",
"(",
"$",
"this",
"->",
"Value",
"(",
"'EMail'",
")",
")",
";",
"$",
"this",
"->",
"SetPassword",
"(",
")",
";",
"$",
"this",
"->",
"member",
"->",
"Save",
"(",
")",
";",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"self",
"::",
"Guard",
"(",
")",
"->",
"GetUser",
"(",
")",
")",
";",
"$",
"logger",
"->",
"ReportMemberAction",
"(",
"$",
"thos",
"->",
"member",
",",
"$",
"action",
")",
";",
"if",
"(",
"$",
"this",
"->",
"groupsExist",
"&&",
"$",
"this",
"->",
"CanAssignGroup",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SaveGroups",
"(",
")",
";",
"}",
"Response",
"::",
"Redirect",
"(",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"MemberList",
"(",
")",
")",
")",
";",
"}"
] | Saves the user | [
"Saves",
"the",
"user"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MemberForm.php#L106-L120 | train |
agentmedia/phine-core | src/Core/Modules/Backend/MemberForm.php | MemberForm.DeleteOldGroups | private function DeleteOldGroups(array $selGroupIDs)
{
$tblMmg = MemberMembergroup::Schema()->Table();
$sql = Access::SqlBuilder();
$where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($this->member->GetID()));
if (count($selGroupIDs) > 0)
{
$selectedList = $sql->InListFromValues($selGroupIDs);
$where = $where->And_($sql->NotIn($tblMmg->Field('MemberGroup'), $selectedList));
}
MemberMembergroup::Schema()->Delete($where);
} | php | private function DeleteOldGroups(array $selGroupIDs)
{
$tblMmg = MemberMembergroup::Schema()->Table();
$sql = Access::SqlBuilder();
$where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($this->member->GetID()));
if (count($selGroupIDs) > 0)
{
$selectedList = $sql->InListFromValues($selGroupIDs);
$where = $where->And_($sql->NotIn($tblMmg->Field('MemberGroup'), $selectedList));
}
MemberMembergroup::Schema()->Delete($where);
} | [
"private",
"function",
"DeleteOldGroups",
"(",
"array",
"$",
"selGroupIDs",
")",
"{",
"$",
"tblMmg",
"=",
"MemberMembergroup",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblMmg",
"->",
"Field",
"(",
"'Member'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"this",
"->",
"member",
"->",
"GetID",
"(",
")",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"selGroupIDs",
")",
">",
"0",
")",
"{",
"$",
"selectedList",
"=",
"$",
"sql",
"->",
"InListFromValues",
"(",
"$",
"selGroupIDs",
")",
";",
"$",
"where",
"=",
"$",
"where",
"->",
"And_",
"(",
"$",
"sql",
"->",
"NotIn",
"(",
"$",
"tblMmg",
"->",
"Field",
"(",
"'MemberGroup'",
")",
",",
"$",
"selectedList",
")",
")",
";",
"}",
"MemberMembergroup",
"::",
"Schema",
"(",
")",
"->",
"Delete",
"(",
"$",
"where",
")",
";",
"}"
] | Deletes the unselected group ids
@param array $exGroupIDs Currently assigned group ids
@param array $selGroupIDs Selected group ids | [
"Deletes",
"the",
"unselected",
"group",
"ids"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MemberForm.php#L159-L170 | train |
agentmedia/phine-core | src/Core/Modules/Backend/MemberForm.php | MemberForm.SaveNewGroups | private function SaveNewGroups(array $exGroupIDs, array $selGroupIDs)
{
foreach ($selGroupIDs as $selGroupID)
{
if (!in_array($selGroupID, $exGroupIDs))
{
$mmg = new MemberMembergroup();
$mmg->SetMember($this->member);
$mmg->SetMemberGroup(new Membergroup($selGroupID));
$mmg->Save();
}
}
} | php | private function SaveNewGroups(array $exGroupIDs, array $selGroupIDs)
{
foreach ($selGroupIDs as $selGroupID)
{
if (!in_array($selGroupID, $exGroupIDs))
{
$mmg = new MemberMembergroup();
$mmg->SetMember($this->member);
$mmg->SetMemberGroup(new Membergroup($selGroupID));
$mmg->Save();
}
}
} | [
"private",
"function",
"SaveNewGroups",
"(",
"array",
"$",
"exGroupIDs",
",",
"array",
"$",
"selGroupIDs",
")",
"{",
"foreach",
"(",
"$",
"selGroupIDs",
"as",
"$",
"selGroupID",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"selGroupID",
",",
"$",
"exGroupIDs",
")",
")",
"{",
"$",
"mmg",
"=",
"new",
"MemberMembergroup",
"(",
")",
";",
"$",
"mmg",
"->",
"SetMember",
"(",
"$",
"this",
"->",
"member",
")",
";",
"$",
"mmg",
"->",
"SetMemberGroup",
"(",
"new",
"Membergroup",
"(",
"$",
"selGroupID",
")",
")",
";",
"$",
"mmg",
"->",
"Save",
"(",
")",
";",
"}",
"}",
"}"
] | Saves the new groups
@param array $exGroupIDs
@param array $selGroupIDs | [
"Saves",
"the",
"new",
"groups"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/MemberForm.php#L176-L188 | train |
indigoram89/laravel-fields | src/Field.php | Field.setDefaultValue | public function setDefaultValue($value = null)
{
if (! $this->value) {
if ($value = $value ?: config("fields.values.{$this->key}")) {
foreach ((array) $value as $locale => $translation) {
$locale = is_string($locale) ? $locale : $this->getDefaultLocale();
$this->setTranslation('value', $translation, $locale);
$this->addTranslated($locale);
}
}
}
} | php | public function setDefaultValue($value = null)
{
if (! $this->value) {
if ($value = $value ?: config("fields.values.{$this->key}")) {
foreach ((array) $value as $locale => $translation) {
$locale = is_string($locale) ? $locale : $this->getDefaultLocale();
$this->setTranslation('value', $translation, $locale);
$this->addTranslated($locale);
}
}
}
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"=",
"$",
"value",
"?",
":",
"config",
"(",
"\"fields.values.{$this->key}\"",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"value",
"as",
"$",
"locale",
"=>",
"$",
"translation",
")",
"{",
"$",
"locale",
"=",
"is_string",
"(",
"$",
"locale",
")",
"?",
"$",
"locale",
":",
"$",
"this",
"->",
"getDefaultLocale",
"(",
")",
";",
"$",
"this",
"->",
"setTranslation",
"(",
"'value'",
",",
"$",
"translation",
",",
"$",
"locale",
")",
";",
"$",
"this",
"->",
"addTranslated",
"(",
"$",
"locale",
")",
";",
"}",
"}",
"}",
"}"
] | Check if value is not set and set it.
@param string|array|null $value
@return void | [
"Check",
"if",
"value",
"is",
"not",
"set",
"and",
"set",
"it",
"."
] | 1cb34eb4e653b82577531951ed94bd73a1009112 | https://github.com/indigoram89/laravel-fields/blob/1cb34eb4e653b82577531951ed94bd73a1009112/src/Field.php#L39-L50 | train |
indigoram89/laravel-fields | src/Field.php | Field.setDefaultDescription | public function setDefaultDescription($description = null)
{
if (! $this->description) {
$description = $description ?: config("fields.descriptions.{$this->key}", ucfirst($this->key));
foreach ((array) $description as $locale => $translation) {
$locale = is_string($locale) ? $locale : $this->getDefaultLocale();
$this->setTranslation('description', $translation, $locale);
}
}
} | php | public function setDefaultDescription($description = null)
{
if (! $this->description) {
$description = $description ?: config("fields.descriptions.{$this->key}", ucfirst($this->key));
foreach ((array) $description as $locale => $translation) {
$locale = is_string($locale) ? $locale : $this->getDefaultLocale();
$this->setTranslation('description', $translation, $locale);
}
}
} | [
"public",
"function",
"setDefaultDescription",
"(",
"$",
"description",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"description",
")",
"{",
"$",
"description",
"=",
"$",
"description",
"?",
":",
"config",
"(",
"\"fields.descriptions.{$this->key}\"",
",",
"ucfirst",
"(",
"$",
"this",
"->",
"key",
")",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"description",
"as",
"$",
"locale",
"=>",
"$",
"translation",
")",
"{",
"$",
"locale",
"=",
"is_string",
"(",
"$",
"locale",
")",
"?",
"$",
"locale",
":",
"$",
"this",
"->",
"getDefaultLocale",
"(",
")",
";",
"$",
"this",
"->",
"setTranslation",
"(",
"'description'",
",",
"$",
"translation",
",",
"$",
"locale",
")",
";",
"}",
"}",
"}"
] | Check if description is not set and set it.
@param string|array|null $description
@return void | [
"Check",
"if",
"description",
"is",
"not",
"set",
"and",
"set",
"it",
"."
] | 1cb34eb4e653b82577531951ed94bd73a1009112 | https://github.com/indigoram89/laravel-fields/blob/1cb34eb4e653b82577531951ed94bd73a1009112/src/Field.php#L58-L67 | train |
indigoram89/laravel-fields | src/Field.php | Field.addTranslated | public function addTranslated(string $locale)
{
if ($this->isDefaultLocale($locale)) {
$this->translated = [$locale];
} else {
$translated = $this->getTranslated();
$translated[] = $locale;
$this->translated = array_unique($translated);
}
} | php | public function addTranslated(string $locale)
{
if ($this->isDefaultLocale($locale)) {
$this->translated = [$locale];
} else {
$translated = $this->getTranslated();
$translated[] = $locale;
$this->translated = array_unique($translated);
}
} | [
"public",
"function",
"addTranslated",
"(",
"string",
"$",
"locale",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDefaultLocale",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"this",
"->",
"translated",
"=",
"[",
"$",
"locale",
"]",
";",
"}",
"else",
"{",
"$",
"translated",
"=",
"$",
"this",
"->",
"getTranslated",
"(",
")",
";",
"$",
"translated",
"[",
"]",
"=",
"$",
"locale",
";",
"$",
"this",
"->",
"translated",
"=",
"array_unique",
"(",
"$",
"translated",
")",
";",
"}",
"}"
] | Set translated locale.
@param string $locale
@return void | [
"Set",
"translated",
"locale",
"."
] | 1cb34eb4e653b82577531951ed94bd73a1009112 | https://github.com/indigoram89/laravel-fields/blob/1cb34eb4e653b82577531951ed94bd73a1009112/src/Field.php#L85-L94 | train |
koolkode/http | src/Http.php | Http.normalizeHeaderName | public static function normalizeHeaderName($name)
{
return preg_replace_callback("'-[a-z]'", function($m) {
return strtoupper($m[0]);
}, ucfirst(strtolower(trim($name))));
} | php | public static function normalizeHeaderName($name)
{
return preg_replace_callback("'-[a-z]'", function($m) {
return strtoupper($m[0]);
}, ucfirst(strtolower(trim($name))));
} | [
"public",
"static",
"function",
"normalizeHeaderName",
"(",
"$",
"name",
")",
"{",
"return",
"preg_replace_callback",
"(",
"\"'-[a-z]'\"",
",",
"function",
"(",
"$",
"m",
")",
"{",
"return",
"strtoupper",
"(",
"$",
"m",
"[",
"0",
"]",
")",
";",
"}",
",",
"ucfirst",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"name",
")",
")",
")",
")",
";",
"}"
] | Normalize an HTTP header name by capitalizing the first letter and all letters
preceeded by a dash.
@param string $name
@return string | [
"Normalize",
"an",
"HTTP",
"header",
"name",
"by",
"capitalizing",
"the",
"first",
"letter",
"and",
"all",
"letters",
"preceeded",
"by",
"a",
"dash",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/Http.php#L834-L839 | train |
p2made/yii2-p2y2-base | assets/P2AssetBase.php | P2AssetBase.useStatic | protected static function useStatic()
{
if(isset(self::$_useStatic)) {
return self::$_useStatic;
}
self::$_useStatic = AssetsSettings::assetsUseStatic();
return self::$_useStatic;
} | php | protected static function useStatic()
{
if(isset(self::$_useStatic)) {
return self::$_useStatic;
}
self::$_useStatic = AssetsSettings::assetsUseStatic();
return self::$_useStatic;
} | [
"protected",
"static",
"function",
"useStatic",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_useStatic",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_useStatic",
";",
"}",
"self",
"::",
"$",
"_useStatic",
"=",
"AssetsSettings",
"::",
"assetsUseStatic",
"(",
")",
";",
"return",
"self",
"::",
"$",
"_useStatic",
";",
"}"
] | Get useStatic setting - use static resources
@return boolean
@default false | [
"Get",
"useStatic",
"setting",
"-",
"use",
"static",
"resources"
] | face3df8794407cdc8178ed64c06cc760c449de2 | https://github.com/p2made/yii2-p2y2-base/blob/face3df8794407cdc8178ed64c06cc760c449de2/assets/P2AssetBase.php#L215-L224 | train |
ezra-obiwale/dSCore | src/Core/AController.php | AController.setView | final public function setView(View $view) {
$this->view = $view;
if (!$this->initializedView) {
$this->initializedView = true;
$this->init();
}
return $this;
} | php | final public function setView(View $view) {
$this->view = $view;
if (!$this->initializedView) {
$this->initializedView = true;
$this->init();
}
return $this;
} | [
"final",
"public",
"function",
"setView",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"$",
"view",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"initializedView",
")",
"{",
"$",
"this",
"->",
"initializedView",
"=",
"true",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the view instance to use
@param View $view
@return AController | [
"Sets",
"the",
"view",
"instance",
"to",
"use"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AController.php#L44-L51 | train |
ezra-obiwale/dSCore | src/Core/AController.php | AController.resetUserIdentity | final protected function resetUserIdentity(AUser $user = null, $duration = null) {
engine('resetUserIdentity', $user, $duration);
return $this;
} | php | final protected function resetUserIdentity(AUser $user = null, $duration = null) {
engine('resetUserIdentity', $user, $duration);
return $this;
} | [
"final",
"protected",
"function",
"resetUserIdentity",
"(",
"AUser",
"$",
"user",
"=",
"null",
",",
"$",
"duration",
"=",
"null",
")",
"{",
"engine",
"(",
"'resetUserIdentity'",
",",
"$",
"user",
",",
"$",
"duration",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Resets the user identity to guest
@param AUser $user
@param int $duration Duration for which the identity should be valid
@return AController | [
"Resets",
"the",
"user",
"identity",
"to",
"guest"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AController.php#L88-L91 | train |
ezra-obiwale/dSCore | src/Core/AController.php | AController.prepareInject | final protected function prepareInject() {
$service = $this->getModule() . '\Services\\' . $this->getClassName() . 'Service';
if (class_exists($service)) {
return array_merge(parent::prepareInject(), $this->getConfigInject('controllers'), array(
'service' => array(
'class' => $service
),
));
}
return array_merge($this->getConfigInject('controllers'), $this->inject());
} | php | final protected function prepareInject() {
$service = $this->getModule() . '\Services\\' . $this->getClassName() . 'Service';
if (class_exists($service)) {
return array_merge(parent::prepareInject(), $this->getConfigInject('controllers'), array(
'service' => array(
'class' => $service
),
));
}
return array_merge($this->getConfigInject('controllers'), $this->inject());
} | [
"final",
"protected",
"function",
"prepareInject",
"(",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
".",
"'\\Services\\\\'",
".",
"$",
"this",
"->",
"getClassName",
"(",
")",
".",
"'Service'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"service",
")",
")",
"{",
"return",
"array_merge",
"(",
"parent",
"::",
"prepareInject",
"(",
")",
",",
"$",
"this",
"->",
"getConfigInject",
"(",
"'controllers'",
")",
",",
"array",
"(",
"'service'",
"=>",
"array",
"(",
"'class'",
"=>",
"$",
"service",
")",
",",
")",
")",
";",
"}",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getConfigInject",
"(",
"'controllers'",
")",
",",
"$",
"this",
"->",
"inject",
"(",
")",
")",
";",
"}"
] | Prepares the injection
@return array | [
"Prepares",
"the",
"injection"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AController.php#L97-L108 | train |
ezra-obiwale/dSCore | src/Core/AController.php | AController.getActions | final public function getActions() {
$return = array();
foreach (get_class_methods($this) as $method) {
if (substr($method, strlen($method) - 6) === 'Action')
$return[] = substr($method, 0, strlen($method) - 6);
}
return $return;
} | php | final public function getActions() {
$return = array();
foreach (get_class_methods($this) as $method) {
if (substr($method, strlen($method) - 6) === 'Action')
$return[] = substr($method, 0, strlen($method) - 6);
}
return $return;
} | [
"final",
"public",
"function",
"getActions",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"get_class_methods",
"(",
"$",
"this",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"method",
",",
"strlen",
"(",
"$",
"method",
")",
"-",
"6",
")",
"===",
"'Action'",
")",
"$",
"return",
"[",
"]",
"=",
"substr",
"(",
"$",
"method",
",",
"0",
",",
"strlen",
"(",
"$",
"method",
")",
"-",
"6",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Fetches all actions in the controller
@return array | [
"Fetches",
"all",
"actions",
"in",
"the",
"controller"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AController.php#L122-L129 | train |
ezra-obiwale/dSCore | src/Core/AController.php | AController.redirect | final protected function redirect($module, $controller = null, $action = null, array $params = array(), $hash = null) {
header('Location: ' . $this->view->url($module, $controller, $action, $params, $hash));
exit;
} | php | final protected function redirect($module, $controller = null, $action = null, array $params = array(), $hash = null) {
header('Location: ' . $this->view->url($module, $controller, $action, $params, $hash));
exit;
} | [
"final",
"protected",
"function",
"redirect",
"(",
"$",
"module",
",",
"$",
"controller",
"=",
"null",
",",
"$",
"action",
"=",
"null",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"hash",
"=",
"null",
")",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"view",
"->",
"url",
"(",
"$",
"module",
",",
"$",
"controller",
",",
"$",
"action",
",",
"$",
"params",
",",
"$",
"hash",
")",
")",
";",
"exit",
";",
"}"
] | Redirects to another resource
@param string $module
@param string|null $controller
@param string|null $action
@param array $params
@param string $hash | [
"Redirects",
"to",
"another",
"resource"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AController.php#L147-L150 | train |
OliverMonneke/pennePHP | src/Datatype/Resource.php | Resource.isEmpty | public static function isEmpty($resource)
{
if (!self::isValid($resource) &&
null !== $resource) {
return false;
}
return String::isEmpty($resource);
} | php | public static function isEmpty($resource)
{
if (!self::isValid($resource) &&
null !== $resource) {
return false;
}
return String::isEmpty($resource);
} | [
"public",
"static",
"function",
"isEmpty",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isValid",
"(",
"$",
"resource",
")",
"&&",
"null",
"!==",
"$",
"resource",
")",
"{",
"return",
"false",
";",
"}",
"return",
"String",
"::",
"isEmpty",
"(",
"$",
"resource",
")",
";",
"}"
] | Check if resource is empty
@param resource $resource The resource
@return bool | [
"Check",
"if",
"resource",
"is",
"empty"
] | dd0de7944685a3f1947157e1254fc54b55ff9942 | https://github.com/OliverMonneke/pennePHP/blob/dd0de7944685a3f1947157e1254fc54b55ff9942/src/Datatype/Resource.php#L36-L44 | train |
OliverMonneke/pennePHP | src/Datatype/Resource.php | Resource.isNotEmpty | public static function isNotEmpty($resource)
{
if (!self::isValid($resource) &&
null !== $resource) {
return false;
}
return ($resource !== null && $resource !== '');
} | php | public static function isNotEmpty($resource)
{
if (!self::isValid($resource) &&
null !== $resource) {
return false;
}
return ($resource !== null && $resource !== '');
} | [
"public",
"static",
"function",
"isNotEmpty",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isValid",
"(",
"$",
"resource",
")",
"&&",
"null",
"!==",
"$",
"resource",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"resource",
"!==",
"null",
"&&",
"$",
"resource",
"!==",
"''",
")",
";",
"}"
] | Check if resource is note empty
@param resource $resource The resource
@return bool | [
"Check",
"if",
"resource",
"is",
"note",
"empty"
] | dd0de7944685a3f1947157e1254fc54b55ff9942 | https://github.com/OliverMonneke/pennePHP/blob/dd0de7944685a3f1947157e1254fc54b55ff9942/src/Datatype/Resource.php#L53-L61 | train |
ARCANESOFT/SEO | src/Seeds/PermissionsTableSeeder.php | PermissionsTableSeeder.getPagesSeeds | private function getPagesSeeds()
{
return [
[
'name' => 'Pages - List all pages',
'description' => 'Allow to list all pages.',
'slug' => PagesPolicy::PERMISSION_LIST,
],
[
'name' => 'Pages - View a page',
'description' => 'Allow to display a page.',
'slug' => PagesPolicy::PERMISSION_SHOW,
],
[
'name' => 'Pages - Create a page',
'description' => 'Allow to create a page.',
'slug' => PagesPolicy::PERMISSION_CREATE,
],
[
'name' => 'Pages - Update a page',
'description' => 'Allow to update a page.',
'slug' => PagesPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Pages - Delete a page',
'description' => 'Allow to delete a page.',
'slug' => PagesPolicy::PERMISSION_DELETE,
],
];
} | php | private function getPagesSeeds()
{
return [
[
'name' => 'Pages - List all pages',
'description' => 'Allow to list all pages.',
'slug' => PagesPolicy::PERMISSION_LIST,
],
[
'name' => 'Pages - View a page',
'description' => 'Allow to display a page.',
'slug' => PagesPolicy::PERMISSION_SHOW,
],
[
'name' => 'Pages - Create a page',
'description' => 'Allow to create a page.',
'slug' => PagesPolicy::PERMISSION_CREATE,
],
[
'name' => 'Pages - Update a page',
'description' => 'Allow to update a page.',
'slug' => PagesPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Pages - Delete a page',
'description' => 'Allow to delete a page.',
'slug' => PagesPolicy::PERMISSION_DELETE,
],
];
} | [
"private",
"function",
"getPagesSeeds",
"(",
")",
"{",
"return",
"[",
"[",
"'name'",
"=>",
"'Pages - List all pages'",
",",
"'description'",
"=>",
"'Allow to list all pages.'",
",",
"'slug'",
"=>",
"PagesPolicy",
"::",
"PERMISSION_LIST",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Pages - View a page'",
",",
"'description'",
"=>",
"'Allow to display a page.'",
",",
"'slug'",
"=>",
"PagesPolicy",
"::",
"PERMISSION_SHOW",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Pages - Create a page'",
",",
"'description'",
"=>",
"'Allow to create a page.'",
",",
"'slug'",
"=>",
"PagesPolicy",
"::",
"PERMISSION_CREATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Pages - Update a page'",
",",
"'description'",
"=>",
"'Allow to update a page.'",
",",
"'slug'",
"=>",
"PagesPolicy",
"::",
"PERMISSION_UPDATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Pages - Delete a page'",
",",
"'description'",
"=>",
"'Allow to delete a page.'",
",",
"'slug'",
"=>",
"PagesPolicy",
"::",
"PERMISSION_DELETE",
",",
"]",
",",
"]",
";",
"}"
] | Get the Pages permissions.
@return array | [
"Get",
"the",
"Pages",
"permissions",
"."
] | ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2 | https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Seeds/PermissionsTableSeeder.php#L72-L101 | train |
ARCANESOFT/SEO | src/Seeds/PermissionsTableSeeder.php | PermissionsTableSeeder.getFootersSeeds | private function getFootersSeeds()
{
return [
[
'name' => 'Footers - List all footers',
'description' => 'Allow to list all footers.',
'slug' => FootersPolicy::PERMISSION_LIST,
],
[
'name' => 'Footers - View a footer',
'description' => 'Allow to display a footer.',
'slug' => FootersPolicy::PERMISSION_SHOW,
],
[
'name' => 'Footers - Create a footer',
'description' => 'Allow to create a footer.',
'slug' => FootersPolicy::PERMISSION_CREATE,
],
[
'name' => 'Footers - Update a footer',
'description' => 'Allow to update a footer.',
'slug' => FootersPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Footers - Delete a footer',
'description' => 'Allow to delete a footer.',
'slug' => FootersPolicy::PERMISSION_DELETE,
],
];
} | php | private function getFootersSeeds()
{
return [
[
'name' => 'Footers - List all footers',
'description' => 'Allow to list all footers.',
'slug' => FootersPolicy::PERMISSION_LIST,
],
[
'name' => 'Footers - View a footer',
'description' => 'Allow to display a footer.',
'slug' => FootersPolicy::PERMISSION_SHOW,
],
[
'name' => 'Footers - Create a footer',
'description' => 'Allow to create a footer.',
'slug' => FootersPolicy::PERMISSION_CREATE,
],
[
'name' => 'Footers - Update a footer',
'description' => 'Allow to update a footer.',
'slug' => FootersPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Footers - Delete a footer',
'description' => 'Allow to delete a footer.',
'slug' => FootersPolicy::PERMISSION_DELETE,
],
];
} | [
"private",
"function",
"getFootersSeeds",
"(",
")",
"{",
"return",
"[",
"[",
"'name'",
"=>",
"'Footers - List all footers'",
",",
"'description'",
"=>",
"'Allow to list all footers.'",
",",
"'slug'",
"=>",
"FootersPolicy",
"::",
"PERMISSION_LIST",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Footers - View a footer'",
",",
"'description'",
"=>",
"'Allow to display a footer.'",
",",
"'slug'",
"=>",
"FootersPolicy",
"::",
"PERMISSION_SHOW",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Footers - Create a footer'",
",",
"'description'",
"=>",
"'Allow to create a footer.'",
",",
"'slug'",
"=>",
"FootersPolicy",
"::",
"PERMISSION_CREATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Footers - Update a footer'",
",",
"'description'",
"=>",
"'Allow to update a footer.'",
",",
"'slug'",
"=>",
"FootersPolicy",
"::",
"PERMISSION_UPDATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Footers - Delete a footer'",
",",
"'description'",
"=>",
"'Allow to delete a footer.'",
",",
"'slug'",
"=>",
"FootersPolicy",
"::",
"PERMISSION_DELETE",
",",
"]",
",",
"]",
";",
"}"
] | Get the Footers permissions.
@return array | [
"Get",
"the",
"Footers",
"permissions",
"."
] | ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2 | https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Seeds/PermissionsTableSeeder.php#L108-L137 | train |
ARCANESOFT/SEO | src/Seeds/PermissionsTableSeeder.php | PermissionsTableSeeder.getRedirectsSeeds | private function getRedirectsSeeds()
{
return [
[
'name' => 'Redirects - List all redirections',
'description' => 'Allow to list all redirections.',
'slug' => RedirectsPolicy::PERMISSION_LIST,
],
[
'name' => 'Redirects - View a redirection',
'description' => 'Allow to display a redirection.',
'slug' => RedirectsPolicy::PERMISSION_SHOW,
],
[
'name' => 'Redirects - Create a redirection',
'description' => 'Allow to create a redirection.',
'slug' => RedirectsPolicy::PERMISSION_CREATE,
],
[
'name' => 'Redirects - Update a redirection',
'description' => 'Allow to update a redirection.',
'slug' => RedirectsPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Redirects - Delete a redirection',
'description' => 'Allow to delete a redirection.',
'slug' => RedirectsPolicy::PERMISSION_DELETE,
],
];
} | php | private function getRedirectsSeeds()
{
return [
[
'name' => 'Redirects - List all redirections',
'description' => 'Allow to list all redirections.',
'slug' => RedirectsPolicy::PERMISSION_LIST,
],
[
'name' => 'Redirects - View a redirection',
'description' => 'Allow to display a redirection.',
'slug' => RedirectsPolicy::PERMISSION_SHOW,
],
[
'name' => 'Redirects - Create a redirection',
'description' => 'Allow to create a redirection.',
'slug' => RedirectsPolicy::PERMISSION_CREATE,
],
[
'name' => 'Redirects - Update a redirection',
'description' => 'Allow to update a redirection.',
'slug' => RedirectsPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Redirects - Delete a redirection',
'description' => 'Allow to delete a redirection.',
'slug' => RedirectsPolicy::PERMISSION_DELETE,
],
];
} | [
"private",
"function",
"getRedirectsSeeds",
"(",
")",
"{",
"return",
"[",
"[",
"'name'",
"=>",
"'Redirects - List all redirections'",
",",
"'description'",
"=>",
"'Allow to list all redirections.'",
",",
"'slug'",
"=>",
"RedirectsPolicy",
"::",
"PERMISSION_LIST",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Redirects - View a redirection'",
",",
"'description'",
"=>",
"'Allow to display a redirection.'",
",",
"'slug'",
"=>",
"RedirectsPolicy",
"::",
"PERMISSION_SHOW",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Redirects - Create a redirection'",
",",
"'description'",
"=>",
"'Allow to create a redirection.'",
",",
"'slug'",
"=>",
"RedirectsPolicy",
"::",
"PERMISSION_CREATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Redirects - Update a redirection'",
",",
"'description'",
"=>",
"'Allow to update a redirection.'",
",",
"'slug'",
"=>",
"RedirectsPolicy",
"::",
"PERMISSION_UPDATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Redirects - Delete a redirection'",
",",
"'description'",
"=>",
"'Allow to delete a redirection.'",
",",
"'slug'",
"=>",
"RedirectsPolicy",
"::",
"PERMISSION_DELETE",
",",
"]",
",",
"]",
";",
"}"
] | Get the Redirects permissions.
@return array | [
"Get",
"the",
"Redirects",
"permissions",
"."
] | ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2 | https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Seeds/PermissionsTableSeeder.php#L160-L189 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.render | public function render($tpl, $params = [])
{
$this->setTemplate($tpl);
$this->params = (object) $params;
return $this->retrieve();
} | php | public function render($tpl, $params = [])
{
$this->setTemplate($tpl);
$this->params = (object) $params;
return $this->retrieve();
} | [
"public",
"function",
"render",
"(",
"$",
"tpl",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setTemplate",
"(",
"$",
"tpl",
")",
";",
"$",
"this",
"->",
"params",
"=",
"(",
"object",
")",
"$",
"params",
";",
"return",
"$",
"this",
"->",
"retrieve",
"(",
")",
";",
"}"
] | Set the template name, assign params array and return rendered output in one method.
Call this function in routes and controllers.
@param string $tpl
@param array $params
@return string | [
"Set",
"the",
"template",
"name",
"assign",
"params",
"array",
"and",
"return",
"rendered",
"output",
"in",
"one",
"method",
".",
"Call",
"this",
"function",
"in",
"routes",
"and",
"controllers",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L102-L107 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.setTemplate | public function setTemplate($tpl, $clearParams=true)
{
if ($clearParams) {
$this->clearParams();
}
$this->templateFile = $this->templatesPath.$tpl.'.tpl.php';
} | php | public function setTemplate($tpl, $clearParams=true)
{
if ($clearParams) {
$this->clearParams();
}
$this->templateFile = $this->templatesPath.$tpl.'.tpl.php';
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"tpl",
",",
"$",
"clearParams",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"clearParams",
")",
"{",
"$",
"this",
"->",
"clearParams",
"(",
")",
";",
"}",
"$",
"this",
"->",
"templateFile",
"=",
"$",
"this",
"->",
"templatesPath",
".",
"$",
"tpl",
".",
"'.tpl.php'",
";",
"}"
] | Set the name of the template to be used. Should not include file extension.
@param string $tpl
@param boolean $clearParams
@return void | [
"Set",
"the",
"name",
"of",
"the",
"template",
"to",
"be",
"used",
".",
"Should",
"not",
"include",
"file",
"extension",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L116-L122 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.setTemplatesPath | private function setTemplatesPath($templatesPath)
{
$this->templatesPath = $templatesPath;
if (!is_readable($this->templatesPath)) {
$this->error("Template Root Path ({$this->templatesPath}) does not exist or not readable.");
}
} | php | private function setTemplatesPath($templatesPath)
{
$this->templatesPath = $templatesPath;
if (!is_readable($this->templatesPath)) {
$this->error("Template Root Path ({$this->templatesPath}) does not exist or not readable.");
}
} | [
"private",
"function",
"setTemplatesPath",
"(",
"$",
"templatesPath",
")",
"{",
"$",
"this",
"->",
"templatesPath",
"=",
"$",
"templatesPath",
";",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"this",
"->",
"templatesPath",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"\"Template Root Path ({$this->templatesPath}) does not exist or not readable.\"",
")",
";",
"}",
"}"
] | Set the path to the templates directory.
@param string $templatesPath
@return void | [
"Set",
"the",
"path",
"to",
"the",
"templates",
"directory",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L130-L136 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.protectedInclude | private function protectedInclude()
{
$_tpl = $this;
// View Helpers:
// * Include another view into the current view:
$_view = function ($tplName, $params = []) use ($_tpl) {
$tplCopy = clone $_tpl; // Don't want to mess with the calling template's settings.
echo($tplCopy->render($tplName, $params));
unset($tplCopy);
};
// * Encode html for a 'Safe String'.
$_ss = function ($str) {
return htmlspecialchars($str, ENT_QUOTES);
};
// Extract template parameters into this local namespace.
$allParams = (object) array_merge((array)self::$staticParams, (array)$this->params);
extract(get_object_vars($allParams));
unset($allParams);
// Included template has access to variables local to this function.
include($this->templateFile);
} | php | private function protectedInclude()
{
$_tpl = $this;
// View Helpers:
// * Include another view into the current view:
$_view = function ($tplName, $params = []) use ($_tpl) {
$tplCopy = clone $_tpl; // Don't want to mess with the calling template's settings.
echo($tplCopy->render($tplName, $params));
unset($tplCopy);
};
// * Encode html for a 'Safe String'.
$_ss = function ($str) {
return htmlspecialchars($str, ENT_QUOTES);
};
// Extract template parameters into this local namespace.
$allParams = (object) array_merge((array)self::$staticParams, (array)$this->params);
extract(get_object_vars($allParams));
unset($allParams);
// Included template has access to variables local to this function.
include($this->templateFile);
} | [
"private",
"function",
"protectedInclude",
"(",
")",
"{",
"$",
"_tpl",
"=",
"$",
"this",
";",
"// View Helpers:",
"// * Include another view into the current view:",
"$",
"_view",
"=",
"function",
"(",
"$",
"tplName",
",",
"$",
"params",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"_tpl",
")",
"{",
"$",
"tplCopy",
"=",
"clone",
"$",
"_tpl",
";",
"// Don't want to mess with the calling template's settings.",
"echo",
"(",
"$",
"tplCopy",
"->",
"render",
"(",
"$",
"tplName",
",",
"$",
"params",
")",
")",
";",
"unset",
"(",
"$",
"tplCopy",
")",
";",
"}",
";",
"// * Encode html for a 'Safe String'.",
"$",
"_ss",
"=",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"htmlspecialchars",
"(",
"$",
"str",
",",
"ENT_QUOTES",
")",
";",
"}",
";",
"// Extract template parameters into this local namespace.",
"$",
"allParams",
"=",
"(",
"object",
")",
"array_merge",
"(",
"(",
"array",
")",
"self",
"::",
"$",
"staticParams",
",",
"(",
"array",
")",
"$",
"this",
"->",
"params",
")",
";",
"extract",
"(",
"get_object_vars",
"(",
"$",
"allParams",
")",
")",
";",
"unset",
"(",
"$",
"allParams",
")",
";",
"// Included template has access to variables local to this function.",
"include",
"(",
"$",
"this",
"->",
"templateFile",
")",
";",
"}"
] | Wrap our template include into a method scope.
This allows our template to have access only to the template params.
It also prevents collisions with the global namespace.
This function also defines some template helpers:
$_ss(string $str) - Safe String. Html encode the string.
$_view(string $tplName, array $params) - include another template into the current one.
@return void | [
"Wrap",
"our",
"template",
"include",
"into",
"a",
"method",
"scope",
".",
"This",
"allows",
"our",
"template",
"to",
"have",
"access",
"only",
"to",
"the",
"template",
"params",
".",
"It",
"also",
"prevents",
"collisions",
"with",
"the",
"global",
"namespace",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L213-L236 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.useCache | protected function useCache()
{
// Should we use a cached version?
if ($this->cache && $this->cacheExists()) {
$this->templateOutput = $this->getCache();
if ($this->templateOutput !== false) {
return true;
}
}
return false;
} | php | protected function useCache()
{
// Should we use a cached version?
if ($this->cache && $this->cacheExists()) {
$this->templateOutput = $this->getCache();
if ($this->templateOutput !== false) {
return true;
}
}
return false;
} | [
"protected",
"function",
"useCache",
"(",
")",
"{",
"// Should we use a cached version?",
"if",
"(",
"$",
"this",
"->",
"cache",
"&&",
"$",
"this",
"->",
"cacheExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"templateOutput",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"templateOutput",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine if we can use a cached version of the template and if so, fetch it.
@return bool | [
"Determine",
"if",
"we",
"can",
"use",
"a",
"cached",
"version",
"of",
"the",
"template",
"and",
"if",
"so",
"fetch",
"it",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L276-L286 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.setCacheKey | public function setCacheKey($key)
{
$key = preg_replace('/[^\da-z]/i', '', $key);
if (!empty($key)) {
$this->cacheKey = $key;
}
} | php | public function setCacheKey($key)
{
$key = preg_replace('/[^\da-z]/i', '', $key);
if (!empty($key)) {
$this->cacheKey = $key;
}
} | [
"public",
"function",
"setCacheKey",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"preg_replace",
"(",
"'/[^\\da-z]/i'",
",",
"''",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"cacheKey",
"=",
"$",
"key",
";",
"}",
"}"
] | Manually set a name for the cached file instead of using the md5 of the template name.
@param string $key
@return void | [
"Manually",
"set",
"a",
"name",
"for",
"the",
"cached",
"file",
"instead",
"of",
"using",
"the",
"md5",
"of",
"the",
"template",
"name",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L294-L300 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.cacheExists | public function cacheExists()
{
$cacheFile = $this->getCacheFile();
if (file_exists($cacheFile) && filemtime($cacheFile) > (time()-$this->cachePeriod)) {
return(true);
} else {
return(false);
}
} | php | public function cacheExists()
{
$cacheFile = $this->getCacheFile();
if (file_exists($cacheFile) && filemtime($cacheFile) > (time()-$this->cachePeriod)) {
return(true);
} else {
return(false);
}
} | [
"public",
"function",
"cacheExists",
"(",
")",
"{",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"getCacheFile",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cacheFile",
")",
"&&",
"filemtime",
"(",
"$",
"cacheFile",
")",
">",
"(",
"time",
"(",
")",
"-",
"$",
"this",
"->",
"cachePeriod",
")",
")",
"{",
"return",
"(",
"true",
")",
";",
"}",
"else",
"{",
"return",
"(",
"false",
")",
";",
"}",
"}"
] | Check whether a cache file exists and is not expired.
@return bool | [
"Check",
"whether",
"a",
"cache",
"file",
"exists",
"and",
"is",
"not",
"expired",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L341-L349 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.setCache | protected function setCache()
{
if ($this->cache) {
$cacheFile = $this->getCacheFile();
file_put_contents($cacheFile, $this->templateOutput);
}
} | php | protected function setCache()
{
if ($this->cache) {
$cacheFile = $this->getCacheFile();
file_put_contents($cacheFile, $this->templateOutput);
}
} | [
"protected",
"function",
"setCache",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"getCacheFile",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"cacheFile",
",",
"$",
"this",
"->",
"templateOutput",
")",
";",
"}",
"}"
] | Cache the template if applicable.
@return void | [
"Cache",
"the",
"template",
"if",
"applicable",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L356-L362 | train |
syntaxseed/templateseed | src/TemplateSeed.php | TemplateSeed.getCacheFile | private function getCacheFile()
{
if (is_null($this->cachePath) || !file_exists($this->cachePath)) {
$this->error('Invalid Cache Path. '.$this->cachePath);
return false;
}
$cacheKey = is_null($this->cacheKey) ? md5($this->templateFile) : $this->cacheKey;
return($this->cachePath . $cacheKey);
} | php | private function getCacheFile()
{
if (is_null($this->cachePath) || !file_exists($this->cachePath)) {
$this->error('Invalid Cache Path. '.$this->cachePath);
return false;
}
$cacheKey = is_null($this->cacheKey) ? md5($this->templateFile) : $this->cacheKey;
return($this->cachePath . $cacheKey);
} | [
"private",
"function",
"getCacheFile",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"cachePath",
")",
"||",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"cachePath",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Invalid Cache Path. '",
".",
"$",
"this",
"->",
"cachePath",
")",
";",
"return",
"false",
";",
"}",
"$",
"cacheKey",
"=",
"is_null",
"(",
"$",
"this",
"->",
"cacheKey",
")",
"?",
"md5",
"(",
"$",
"this",
"->",
"templateFile",
")",
":",
"$",
"this",
"->",
"cacheKey",
";",
"return",
"(",
"$",
"this",
"->",
"cachePath",
".",
"$",
"cacheKey",
")",
";",
"}"
] | Get the name of the file this template should be cached to.
Using the supplied key, or the md5 of the template name.
@return string|false | [
"Get",
"the",
"name",
"of",
"the",
"file",
"this",
"template",
"should",
"be",
"cached",
"to",
".",
"Using",
"the",
"supplied",
"key",
"or",
"the",
"md5",
"of",
"the",
"template",
"name",
"."
] | 70e157381fa513e92e566824be18cc4437e7cff9 | https://github.com/syntaxseed/templateseed/blob/70e157381fa513e92e566824be18cc4437e7cff9/src/TemplateSeed.php#L384-L392 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.consume | public function consume($type = NULL)
{
if(!$this->valid())
{
throw new \OutOfBoundsException('No more tokens available');
}
$token = $this->current();
if($type !== NULL && !$token->is($type))
{
throw new \UnexpectedValueException(sprintf('Expected token type %s, read "%s" (%d)', $type, $token, $token->getType()));
}
$this->next();
return $token;
} | php | public function consume($type = NULL)
{
if(!$this->valid())
{
throw new \OutOfBoundsException('No more tokens available');
}
$token = $this->current();
if($type !== NULL && !$token->is($type))
{
throw new \UnexpectedValueException(sprintf('Expected token type %s, read "%s" (%d)', $type, $token, $token->getType()));
}
$this->next();
return $token;
} | [
"public",
"function",
"consume",
"(",
"$",
"type",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'No more tokens available'",
")",
";",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"type",
"!==",
"NULL",
"&&",
"!",
"$",
"token",
"->",
"is",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'Expected token type %s, read \"%s\" (%d)'",
",",
"$",
"type",
",",
"$",
"token",
",",
"$",
"token",
"->",
"getType",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"next",
"(",
")",
";",
"return",
"$",
"token",
";",
"}"
] | Consume the next token and return it.
@param integer $type The expected token type...
@return AbstractToken
@throws \OutOfBoundsException When there are no more tokens to be consumed.
@throws \UnexpectedValueException When a token is found but does not match the given type. | [
"Consume",
"the",
"next",
"token",
"and",
"return",
"it",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L113-L130 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.moveTo | public function moveTo($mark)
{
if(is_array($mark) || $mark instanceof \Countable)
{
$this->index = count($mark);
}
else
{
$this->index = (int)$mark;
}
return $this;
} | php | public function moveTo($mark)
{
if(is_array($mark) || $mark instanceof \Countable)
{
$this->index = count($mark);
}
else
{
$this->index = (int)$mark;
}
return $this;
} | [
"public",
"function",
"moveTo",
"(",
"$",
"mark",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mark",
")",
"||",
"$",
"mark",
"instanceof",
"\\",
"Countable",
")",
"{",
"$",
"this",
"->",
"index",
"=",
"count",
"(",
"$",
"mark",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"index",
"=",
"(",
"int",
")",
"$",
"mark",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Moves the cursor to the given mark.
@param mixed $mark
@return AbstractTokenCursor | [
"Moves",
"the",
"cursor",
"to",
"the",
"given",
"mark",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L161-L173 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.move | public function move($steps)
{
if(is_array($steps) || $steps instanceof \Countable)
{
$this->index += count($steps);
}
else
{
$this->index += (int)$steps;
}
return $this;
} | php | public function move($steps)
{
if(is_array($steps) || $steps instanceof \Countable)
{
$this->index += count($steps);
}
else
{
$this->index += (int)$steps;
}
return $this;
} | [
"public",
"function",
"move",
"(",
"$",
"steps",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"steps",
")",
"||",
"$",
"steps",
"instanceof",
"\\",
"Countable",
")",
"{",
"$",
"this",
"->",
"index",
"+=",
"count",
"(",
"$",
"steps",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"index",
"+=",
"(",
"int",
")",
"$",
"steps",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Move the cursor by the given number of steps.
@param mixed $steps
@return AbstractTokenCursor | [
"Move",
"the",
"cursor",
"by",
"the",
"given",
"number",
"of",
"steps",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L181-L193 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.moveToNext | public function moveToNext($type, callable $callback = NULL)
{
$delim = (array)$type;
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($delim))
{
return $token;
}
if($callback !== NULL)
{
$callback($token);
}
$this->next();
}
} | php | public function moveToNext($type, callable $callback = NULL)
{
$delim = (array)$type;
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($delim))
{
return $token;
}
if($callback !== NULL)
{
$callback($token);
}
$this->next();
}
} | [
"public",
"function",
"moveToNext",
"(",
"$",
"type",
",",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"$",
"delim",
"=",
"(",
"array",
")",
"$",
"type",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"delim",
")",
")",
"{",
"return",
"$",
"token",
";",
"}",
"if",
"(",
"$",
"callback",
"!==",
"NULL",
")",
"{",
"$",
"callback",
"(",
"$",
"token",
")",
";",
"}",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"}"
] | Move the cursor to the next occurance if the given token type.
@param mixed $type The target token type.
@param callable $callback Is invoked once for every skipped token.
@return AbstractToken or <code>NULL</code> if no token was found. | [
"Move",
"the",
"cursor",
"to",
"the",
"next",
"occurance",
"if",
"the",
"given",
"token",
"type",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L228-L248 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.readSequence | public function readSequence(array $allowedTokenTypes)
{
$tokens = [];
while($this->valid())
{
$token = $this->current();
if(!$token->isOneOf($allowedTokenTypes))
{
break;
}
$tokens[] = $token;
$this->next();
}
return $this->createTokenSequence($tokens);
} | php | public function readSequence(array $allowedTokenTypes)
{
$tokens = [];
while($this->valid())
{
$token = $this->current();
if(!$token->isOneOf($allowedTokenTypes))
{
break;
}
$tokens[] = $token;
$this->next();
}
return $this->createTokenSequence($tokens);
} | [
"public",
"function",
"readSequence",
"(",
"array",
"$",
"allowedTokenTypes",
")",
"{",
"$",
"tokens",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"allowedTokenTypes",
")",
")",
"{",
"break",
";",
"}",
"$",
"tokens",
"[",
"]",
"=",
"$",
"token",
";",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createTokenSequence",
"(",
"$",
"tokens",
")",
";",
"}"
] | Get a TokenSequence containing only the allowed token types starting from the
current position of the cursor.
@param array<integer> $allowedTokenTypes
@return AbstractTokenSequence | [
"Get",
"a",
"TokenSequence",
"containing",
"only",
"the",
"allowed",
"token",
"types",
"starting",
"from",
"the",
"current",
"position",
"of",
"the",
"cursor",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L257-L276 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.readSequenceToNext | public function readSequenceToNext($type, $skipDelimiter = false)
{
$tokens = [];
$delim = (array)$type;
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($delim))
{
if(!$skipDelimiter)
{
$tokens[] = $token;
}
break;
}
$tokens[] = $token;
$this->next();
}
return $this->createTokenSequence($tokens);
} | php | public function readSequenceToNext($type, $skipDelimiter = false)
{
$tokens = [];
$delim = (array)$type;
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($delim))
{
if(!$skipDelimiter)
{
$tokens[] = $token;
}
break;
}
$tokens[] = $token;
$this->next();
}
return $this->createTokenSequence($tokens);
} | [
"public",
"function",
"readSequenceToNext",
"(",
"$",
"type",
",",
"$",
"skipDelimiter",
"=",
"false",
")",
"{",
"$",
"tokens",
"=",
"[",
"]",
";",
"$",
"delim",
"=",
"(",
"array",
")",
"$",
"type",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"delim",
")",
")",
"{",
"if",
"(",
"!",
"$",
"skipDelimiter",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"$",
"token",
";",
"}",
"break",
";",
"}",
"$",
"tokens",
"[",
"]",
"=",
"$",
"token",
";",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createTokenSequence",
"(",
"$",
"tokens",
")",
";",
"}"
] | Read tokens to the next occurance of the given token type and return a
token sequence containing all found tokens.
@param mixed $type
@param boolean $skipDelimiter
@return AbstractTokenSequence | [
"Read",
"tokens",
"to",
"the",
"next",
"occurance",
"of",
"the",
"given",
"token",
"type",
"and",
"return",
"a",
"token",
"sequence",
"containing",
"all",
"found",
"tokens",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L286-L311 | train |
koolkode/lexer | src/AbstractTokenCursor.php | AbstractTokenCursor.readNextBlock | public function readNextBlock($openingDelimiter, $closingDelimiter, $skipDelimiters = true)
{
$od = (array)$openingDelimiter;
$cd = (array)$closingDelimiter;
$tokens = [];
$level = -1;
while($this->valid() && $level < 0)
{
$token = $this->current();
if($token->isOneOf($od))
{
$level = 0;
break;
}
$this->next();
}
if($level == 0)
{
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($od))
{
$level++;
}
elseif($token->isOneOf($cd))
{
$level--;
}
$tokens[] = $token;
if($level == 0)
{
$this->next();
break;
}
$this->next();
}
}
if($skipDelimiters)
{
return $this->createTokenSequence(array_slice($tokens, 1, count($tokens) - 2));
}
return $this->createTokenSequence($tokens);
} | php | public function readNextBlock($openingDelimiter, $closingDelimiter, $skipDelimiters = true)
{
$od = (array)$openingDelimiter;
$cd = (array)$closingDelimiter;
$tokens = [];
$level = -1;
while($this->valid() && $level < 0)
{
$token = $this->current();
if($token->isOneOf($od))
{
$level = 0;
break;
}
$this->next();
}
if($level == 0)
{
while($this->valid())
{
$token = $this->current();
if($token->isOneOf($od))
{
$level++;
}
elseif($token->isOneOf($cd))
{
$level--;
}
$tokens[] = $token;
if($level == 0)
{
$this->next();
break;
}
$this->next();
}
}
if($skipDelimiters)
{
return $this->createTokenSequence(array_slice($tokens, 1, count($tokens) - 2));
}
return $this->createTokenSequence($tokens);
} | [
"public",
"function",
"readNextBlock",
"(",
"$",
"openingDelimiter",
",",
"$",
"closingDelimiter",
",",
"$",
"skipDelimiters",
"=",
"true",
")",
"{",
"$",
"od",
"=",
"(",
"array",
")",
"$",
"openingDelimiter",
";",
"$",
"cd",
"=",
"(",
"array",
")",
"$",
"closingDelimiter",
";",
"$",
"tokens",
"=",
"[",
"]",
";",
"$",
"level",
"=",
"-",
"1",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
"&&",
"$",
"level",
"<",
"0",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"od",
")",
")",
"{",
"$",
"level",
"=",
"0",
";",
"break",
";",
"}",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"if",
"(",
"$",
"level",
"==",
"0",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"od",
")",
")",
"{",
"$",
"level",
"++",
";",
"}",
"elseif",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"cd",
")",
")",
"{",
"$",
"level",
"--",
";",
"}",
"$",
"tokens",
"[",
"]",
"=",
"$",
"token",
";",
"if",
"(",
"$",
"level",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"next",
"(",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"skipDelimiters",
")",
"{",
"return",
"$",
"this",
"->",
"createTokenSequence",
"(",
"array_slice",
"(",
"$",
"tokens",
",",
"1",
",",
"count",
"(",
"$",
"tokens",
")",
"-",
"2",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createTokenSequence",
"(",
"$",
"tokens",
")",
";",
"}"
] | Reads the next code block enclosed in the given delimiters, returns an
empty token sequence when no tokens were matched.
@param mixed $openingDelimiter
@param mixed $closingDelimiter
@param boolean $skipDelimiters Skip enclosing delimiters?
@return AbstractTokenSequence | [
"Reads",
"the",
"next",
"code",
"block",
"enclosed",
"in",
"the",
"given",
"delimiters",
"returns",
"an",
"empty",
"token",
"sequence",
"when",
"no",
"tokens",
"were",
"matched",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenCursor.php#L322-L378 | train |
brightnucleus/localization | src/LocalizationTrait.php | LocalizationTrait.loadLocalization | protected function loadLocalization( $domain, $path ) {
if ( is_textdomain_loaded( $domain ) ) {
return;
}
$locale = get_locale();
/**
* Filter the locale of a Bright Nucleus library.
*
* @since v0.1.0
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving
* translated strings.
* @return string $locale Filtered locale.
*/
$locale = apply_filters(
Localization::LOCALE_FILTER,
$locale,
$domain
);
/**
* Filter the name of the MO-file of a Bright Nucleus library.
*
* @since v0.1.0
*
* @param string $path Path to the MO-file.
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving
* translated strings.
* @return string $path Filtered path to the MO-file.
*/
$mofile = apply_filters(
Localization::MOFILE_FILTER,
sprintf(
'%1$s/%2$s-%3$s.mo',
$path,
$domain,
$locale
),
$locale,
$domain
);
return load_textdomain(
$domain,
$mofile
);
} | php | protected function loadLocalization( $domain, $path ) {
if ( is_textdomain_loaded( $domain ) ) {
return;
}
$locale = get_locale();
/**
* Filter the locale of a Bright Nucleus library.
*
* @since v0.1.0
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving
* translated strings.
* @return string $locale Filtered locale.
*/
$locale = apply_filters(
Localization::LOCALE_FILTER,
$locale,
$domain
);
/**
* Filter the name of the MO-file of a Bright Nucleus library.
*
* @since v0.1.0
*
* @param string $path Path to the MO-file.
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving
* translated strings.
* @return string $path Filtered path to the MO-file.
*/
$mofile = apply_filters(
Localization::MOFILE_FILTER,
sprintf(
'%1$s/%2$s-%3$s.mo',
$path,
$domain,
$locale
),
$locale,
$domain
);
return load_textdomain(
$domain,
$mofile
);
} | [
"protected",
"function",
"loadLocalization",
"(",
"$",
"domain",
",",
"$",
"path",
")",
"{",
"if",
"(",
"is_textdomain_loaded",
"(",
"$",
"domain",
")",
")",
"{",
"return",
";",
"}",
"$",
"locale",
"=",
"get_locale",
"(",
")",
";",
"/**\n\t\t * Filter the locale of a Bright Nucleus library.\n\t\t *\n\t\t * @since v0.1.0\n\t\t *\n\t\t * @param string $locale The plugin's current locale.\n\t\t * @param string $domain Text domain. Unique identifier for retrieving\n\t\t * translated strings.\n\t\t * @return string $locale Filtered locale.\n\t\t */",
"$",
"locale",
"=",
"apply_filters",
"(",
"Localization",
"::",
"LOCALE_FILTER",
",",
"$",
"locale",
",",
"$",
"domain",
")",
";",
"/**\n\t\t * Filter the name of the MO-file of a Bright Nucleus library.\n\t\t *\n\t\t * @since v0.1.0\n\t\t *\n\t\t * @param string $path Path to the MO-file.\n\t\t * @param string $locale The plugin's current locale.\n\t\t * @param string $domain Text domain. Unique identifier for retrieving\n\t\t * translated strings.\n\t\t * @return string $path Filtered path to the MO-file.\n\t\t */",
"$",
"mofile",
"=",
"apply_filters",
"(",
"Localization",
"::",
"MOFILE_FILTER",
",",
"sprintf",
"(",
"'%1$s/%2$s-%3$s.mo'",
",",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"locale",
")",
",",
"$",
"locale",
",",
"$",
"domain",
")",
";",
"return",
"load_textdomain",
"(",
"$",
"domain",
",",
"$",
"mofile",
")",
";",
"}"
] | Load localized strings.
@since 0.1.0
@param string $domain Textdomain to load.
@param string $path Path to languages files. | [
"Load",
"localized",
"strings",
"."
] | 8705bcccf54f4b19d50ed871364d6a6c2b8cffcd | https://github.com/brightnucleus/localization/blob/8705bcccf54f4b19d50ed871364d6a6c2b8cffcd/src/LocalizationTrait.php#L34-L84 | train |
andres-montanez/FragmentCacheBundle | Service/FileCacheService.php | FileCacheService.get | public function get($key)
{
$file = $this->cacheDir . $this->getDir($key) . $this->getFile($key);
if (file_exists($file) && is_readable($file)) {
if (filemtime($file) > time()) {
return file_get_contents($file);
}
}
return false;
} | php | public function get($key)
{
$file = $this->cacheDir . $this->getDir($key) . $this->getFile($key);
if (file_exists($file) && is_readable($file)) {
if (filemtime($file) > time()) {
return file_get_contents($file);
}
}
return false;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"cacheDir",
".",
"$",
"this",
"->",
"getDir",
"(",
"$",
"key",
")",
".",
"$",
"this",
"->",
"getFile",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"filemtime",
"(",
"$",
"file",
")",
">",
"time",
"(",
")",
")",
"{",
"return",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Get a stored value by it's key
@param string $key
@return mixed | [
"Get",
"a",
"stored",
"value",
"by",
"it",
"s",
"key"
] | 90f9511e275fd78990f6b90cd52052078c53253a | https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/Service/FileCacheService.php#L47-L57 | train |
andres-montanez/FragmentCacheBundle | Service/FileCacheService.php | FileCacheService.set | public function set($key, $value, $expiration = 0)
{
$file = $this->cacheDir . $this->getDir($key) . $this->getFile($key);
if (!file_exists(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
$return = file_put_contents($file, $value);
touch($file, time() + $expiration);
return $return;
} | php | public function set($key, $value, $expiration = 0)
{
$file = $this->cacheDir . $this->getDir($key) . $this->getFile($key);
if (!file_exists(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
$return = file_put_contents($file, $value);
touch($file, time() + $expiration);
return $return;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expiration",
"=",
"0",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"cacheDir",
".",
"$",
"this",
"->",
"getDir",
"(",
"$",
"key",
")",
".",
"$",
"this",
"->",
"getFile",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"file",
")",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"return",
"=",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"value",
")",
";",
"touch",
"(",
"$",
"file",
",",
"time",
"(",
")",
"+",
"$",
"expiration",
")",
";",
"return",
"$",
"return",
";",
"}"
] | Stores a value in the cache
@param string $key
@param mixed $value
@param integer $expiration
@return boolean | [
"Stores",
"a",
"value",
"in",
"the",
"cache"
] | 90f9511e275fd78990f6b90cd52052078c53253a | https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/Service/FileCacheService.php#L68-L80 | train |
andres-montanez/FragmentCacheBundle | Service/FileCacheService.php | FileCacheService.getDir | protected function getDir($key)
{
$dir = sha1($key);
$dir = substr($dir, 0, 3) . '/'
. substr($dir, 3, 3) . '/';
return $dir;
} | php | protected function getDir($key)
{
$dir = sha1($key);
$dir = substr($dir, 0, 3) . '/'
. substr($dir, 3, 3) . '/';
return $dir;
} | [
"protected",
"function",
"getDir",
"(",
"$",
"key",
")",
"{",
"$",
"dir",
"=",
"sha1",
"(",
"$",
"key",
")",
";",
"$",
"dir",
"=",
"substr",
"(",
"$",
"dir",
",",
"0",
",",
"3",
")",
".",
"'/'",
".",
"substr",
"(",
"$",
"dir",
",",
"3",
",",
"3",
")",
".",
"'/'",
";",
"return",
"$",
"dir",
";",
"}"
] | Calculates the Directory based on a key
@param string $key
@return string | [
"Calculates",
"the",
"Directory",
"based",
"on",
"a",
"key"
] | 90f9511e275fd78990f6b90cd52052078c53253a | https://github.com/andres-montanez/FragmentCacheBundle/blob/90f9511e275fd78990f6b90cd52052078c53253a/Service/FileCacheService.php#L101-L108 | train |
ringoteam/RingoPhpRedmonBundle | Controller/AdminController.php | AdminController.flushAllAction | public function flushAllAction()
{
try {
$this->getWorker()->execute('flushAll');
$this->get('session')->getFlashBag()->add('success', 'Flush ALL executed successfully');
}catch(\Exception $e) {
$this->get('session')->getFlashBag()->add('error', 'We have encountered an error : '.$e->getMessage());
}
return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
} | php | public function flushAllAction()
{
try {
$this->getWorker()->execute('flushAll');
$this->get('session')->getFlashBag()->add('success', 'Flush ALL executed successfully');
}catch(\Exception $e) {
$this->get('session')->getFlashBag()->add('error', 'We have encountered an error : '.$e->getMessage());
}
return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
} | [
"public",
"function",
"flushAllAction",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getWorker",
"(",
")",
"->",
"execute",
"(",
"'flushAll'",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'Flush ALL executed successfully'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'We have encountered an error : '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ringo_php_redmon'",
")",
")",
";",
"}"
] | Call flush all command for the current instance
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Call",
"flush",
"all",
"command",
"for",
"the",
"current",
"instance"
] | 9aab989a9bee9e6152ec19f8a30bc24f3bde6012 | https://github.com/ringoteam/RingoPhpRedmonBundle/blob/9aab989a9bee9e6152ec19f8a30bc24f3bde6012/Controller/AdminController.php#L31-L42 | train |
ringoteam/RingoPhpRedmonBundle | Controller/AdminController.php | AdminController.flushDbAction | public function flushDbAction($id)
{
try {
$this->getWorker()->flushDB($id);
$this->get('session')->getFlashBag()->add('success', 'Flush DB on '.$id.' executed successfully');
}catch(\Exception $e) {
$this->get('session')->getFlashBag()->add('success', 'Une erreur s\'est produite : '.$e->getMessage());
}
return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
} | php | public function flushDbAction($id)
{
try {
$this->getWorker()->flushDB($id);
$this->get('session')->getFlashBag()->add('success', 'Flush DB on '.$id.' executed successfully');
}catch(\Exception $e) {
$this->get('session')->getFlashBag()->add('success', 'Une erreur s\'est produite : '.$e->getMessage());
}
return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
} | [
"public",
"function",
"flushDbAction",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getWorker",
"(",
")",
"->",
"flushDB",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'Flush DB on '",
".",
"$",
"id",
".",
"' executed successfully'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'Une erreur s\\'est produite : '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ringo_php_redmon'",
")",
")",
";",
"}"
] | Call flush DB command for the current instance and the current database
@param int $id Database index
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Call",
"flush",
"DB",
"command",
"for",
"the",
"current",
"instance",
"and",
"the",
"current",
"database"
] | 9aab989a9bee9e6152ec19f8a30bc24f3bde6012 | https://github.com/ringoteam/RingoPhpRedmonBundle/blob/9aab989a9bee9e6152ec19f8a30bc24f3bde6012/Controller/AdminController.php#L50-L61 | train |
wb-crowdfusion/crowdfusion | system/core/classes/mvc/http/Response.php | Response.setProtocol | protected function setProtocol($statuscode)
{
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' || $statuscode == Response::SC_CONTINUE || $statuscode == Response::SC_SWITCHING_PROTOCOLS || $statuscode == Response::SC_TEMPORARY_REDIRECT) {
header('HTTP/1.1 ' . $statuscode);
} elseif (empty($_SERVER['SERVER_PROTOCOL'])) {
header('HTTP/1.0 ' . $statuscode);
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $statuscode);
}
} | php | protected function setProtocol($statuscode)
{
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' || $statuscode == Response::SC_CONTINUE || $statuscode == Response::SC_SWITCHING_PROTOCOLS || $statuscode == Response::SC_TEMPORARY_REDIRECT) {
header('HTTP/1.1 ' . $statuscode);
} elseif (empty($_SERVER['SERVER_PROTOCOL'])) {
header('HTTP/1.0 ' . $statuscode);
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $statuscode);
}
} | [
"protected",
"function",
"setProtocol",
"(",
"$",
"statuscode",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
"==",
"'HTTP/1.1'",
"||",
"$",
"statuscode",
"==",
"Response",
"::",
"SC_CONTINUE",
"||",
"$",
"statuscode",
"==",
"Response",
"::",
"SC_SWITCHING_PROTOCOLS",
"||",
"$",
"statuscode",
"==",
"Response",
"::",
"SC_TEMPORARY_REDIRECT",
")",
"{",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"statuscode",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
")",
"{",
"header",
"(",
"'HTTP/1.0 '",
".",
"$",
"statuscode",
")",
";",
"}",
"else",
"{",
"header",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
".",
"' '",
".",
"$",
"statuscode",
")",
";",
"}",
"}"
] | setProtocol
all response protocol decisions made here
handle the exceptions to rules for protocol 1.1 vs 1.0
default to 1.0 when protocol not specified
RFC @ http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10
@param statuscode $statuscode | [
"setProtocol",
"all",
"response",
"protocol",
"decisions",
"made",
"here",
"handle",
"the",
"exceptions",
"to",
"rules",
"for",
"protocol",
"1",
".",
"1",
"vs",
"1",
".",
"0",
"default",
"to",
"1",
".",
"0",
"when",
"protocol",
"not",
"specified",
"RFC"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/http/Response.php#L143-L152 | train |
TuumPHP/Web | src/Middleware/MiddlewareTrait.php | MiddlewareTrait.push | public function push($handler)
{
if (!$handler) {
return $this;
}
if ($this->next) {
return $this->next->push($handler);
}
if (!$handler instanceof MiddlewareInterface) {
$handler = new Middleware($handler);
}
$this->next = $handler;
return $this->next;
} | php | public function push($handler)
{
if (!$handler) {
return $this;
}
if ($this->next) {
return $this->next->push($handler);
}
if (!$handler instanceof MiddlewareInterface) {
$handler = new Middleware($handler);
}
$this->next = $handler;
return $this->next;
} | [
"public",
"function",
"push",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"$",
"handler",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"next",
")",
"{",
"return",
"$",
"this",
"->",
"next",
"->",
"push",
"(",
"$",
"handler",
")",
";",
"}",
"if",
"(",
"!",
"$",
"handler",
"instanceof",
"MiddlewareInterface",
")",
"{",
"$",
"handler",
"=",
"new",
"Middleware",
"(",
"$",
"handler",
")",
";",
"}",
"$",
"this",
"->",
"next",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
"->",
"next",
";",
"}"
] | stack up the middleware.
converts normal Application into middleware.
@param ApplicationInterface $handler
@return $this | [
"stack",
"up",
"the",
"middleware",
".",
"converts",
"normal",
"Application",
"into",
"middleware",
"."
] | 8f296b6358aa93226ce08d6cc54a309f5b0a9820 | https://github.com/TuumPHP/Web/blob/8f296b6358aa93226ce08d6cc54a309f5b0a9820/src/Middleware/MiddlewareTrait.php#L31-L44 | train |
kaiohken1982/NeobazaarDocumentModule | src/Document/Controller/ImageController.php | ImageController.getClassifiedImageAddForm | public function getClassifiedImageAddForm()
{
if (null === $this->classifiedImageAddForm) {
$this->classifiedImageAddForm = $this->getServiceLocator()->get('document.form.classifiedimageadd');
}
return $this->classifiedImageAddForm;
} | php | public function getClassifiedImageAddForm()
{
if (null === $this->classifiedImageAddForm) {
$this->classifiedImageAddForm = $this->getServiceLocator()->get('document.form.classifiedimageadd');
}
return $this->classifiedImageAddForm;
} | [
"public",
"function",
"getClassifiedImageAddForm",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"classifiedImageAddForm",
")",
"{",
"$",
"this",
"->",
"classifiedImageAddForm",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'document.form.classifiedimageadd'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"classifiedImageAddForm",
";",
"}"
] | Get useradd form
@return \Document\Form\ClassifiedImageAdd | [
"Get",
"useradd",
"form"
] | edb0223878fe02e791d2a0266c5a7c0f2029e3fe | https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Controller/ImageController.php#L109-L115 | train |
netlogix/Netlogix.BehatCommons | Classes/Netlogix/BehatCommons/ObjectFactory.php | ObjectFactory.create | public function create(array $parameters, $className, PropertyMapper $propertyMapper)
{
list ($objectStructure, $propertyPaths) = $this->getNestedStructureForDottedNotation($parameters);
$propertyMappingConfiguration = $this->getPropertyMappingConfigurationForPropertyPaths($propertyPaths, $className);
$result = $propertyMapper->convert($objectStructure, $className, $propertyMappingConfiguration);
if ($this->startObjectTracking) {
$this->createdObjects[] = $result;
}
return $result;
} | php | public function create(array $parameters, $className, PropertyMapper $propertyMapper)
{
list ($objectStructure, $propertyPaths) = $this->getNestedStructureForDottedNotation($parameters);
$propertyMappingConfiguration = $this->getPropertyMappingConfigurationForPropertyPaths($propertyPaths, $className);
$result = $propertyMapper->convert($objectStructure, $className, $propertyMappingConfiguration);
if ($this->startObjectTracking) {
$this->createdObjects[] = $result;
}
return $result;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"parameters",
",",
"$",
"className",
",",
"PropertyMapper",
"$",
"propertyMapper",
")",
"{",
"list",
"(",
"$",
"objectStructure",
",",
"$",
"propertyPaths",
")",
"=",
"$",
"this",
"->",
"getNestedStructureForDottedNotation",
"(",
"$",
"parameters",
")",
";",
"$",
"propertyMappingConfiguration",
"=",
"$",
"this",
"->",
"getPropertyMappingConfigurationForPropertyPaths",
"(",
"$",
"propertyPaths",
",",
"$",
"className",
")",
";",
"$",
"result",
"=",
"$",
"propertyMapper",
"->",
"convert",
"(",
"$",
"objectStructure",
",",
"$",
"className",
",",
"$",
"propertyMappingConfiguration",
")",
";",
"if",
"(",
"$",
"this",
"->",
"startObjectTracking",
")",
"{",
"$",
"this",
"->",
"createdObjects",
"[",
"]",
"=",
"$",
"result",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Creates a new object based in input parameters and a class name.
This is basically a wrapper for the PropertyMapper::convert() method that
does not take a hierarchical source array but only a key=>value map of
keys being dot notation property paths.
@param array $parameters
@param string $className
@param PropertyMapper $propertyMapper
@return mixed | [
"Creates",
"a",
"new",
"object",
"based",
"in",
"input",
"parameters",
"and",
"a",
"class",
"name",
"."
] | bdac586281fd3ebba4ca3a285df903f790feeee0 | https://github.com/netlogix/Netlogix.BehatCommons/blob/bdac586281fd3ebba4ca3a285df903f790feeee0/Classes/Netlogix/BehatCommons/ObjectFactory.php#L88-L98 | train |
netlogix/Netlogix.BehatCommons | Classes/Netlogix/BehatCommons/ObjectFactory.php | ObjectFactory.getPropertyMappingConfigurationForPropertyPaths | public function getPropertyMappingConfigurationForPropertyPaths(array $propertyPaths, $className = '')
{
$propertyMappingConfiguration = new PropertyMappingConfiguration();
$propertyMappingConfiguration->allowAllProperties();
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
foreach ($propertyPaths as $propertyPath) {
$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
$propertyMappingConfiguration->forProperty($propertyPath)->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
}
return $propertyMappingConfiguration;
} | php | public function getPropertyMappingConfigurationForPropertyPaths(array $propertyPaths, $className = '')
{
$propertyMappingConfiguration = new PropertyMappingConfiguration();
$propertyMappingConfiguration->allowAllProperties();
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
foreach ($propertyPaths as $propertyPath) {
$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
$propertyMappingConfiguration->forProperty($propertyPath)->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
}
return $propertyMappingConfiguration;
} | [
"public",
"function",
"getPropertyMappingConfigurationForPropertyPaths",
"(",
"array",
"$",
"propertyPaths",
",",
"$",
"className",
"=",
"''",
")",
"{",
"$",
"propertyMappingConfiguration",
"=",
"new",
"PropertyMappingConfiguration",
"(",
")",
";",
"$",
"propertyMappingConfiguration",
"->",
"allowAllProperties",
"(",
")",
";",
"$",
"propertyMappingConfiguration",
"->",
"setTypeConverterOption",
"(",
"PersistentObjectConverter",
"::",
"class",
",",
"PersistentObjectConverter",
"::",
"CONFIGURATION_CREATION_ALLOWED",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"propertyPaths",
"as",
"$",
"propertyPath",
")",
"{",
"$",
"propertyMappingConfiguration",
"->",
"forProperty",
"(",
"$",
"propertyPath",
")",
"->",
"allowAllProperties",
"(",
")",
";",
"$",
"propertyMappingConfiguration",
"->",
"forProperty",
"(",
"$",
"propertyPath",
")",
"->",
"setTypeConverterOption",
"(",
"PersistentObjectConverter",
"::",
"class",
",",
"PersistentObjectConverter",
"::",
"CONFIGURATION_CREATION_ALLOWED",
",",
"true",
")",
";",
"}",
"return",
"$",
"propertyMappingConfiguration",
";",
"}"
] | Creates a "allow all" property mapping configuration for all properties, even recursively.
@param array <string> $propertyPaths
@param string $className
@return PropertyMappingConfiguration | [
"Creates",
"a",
"allow",
"all",
"property",
"mapping",
"configuration",
"for",
"all",
"properties",
"even",
"recursively",
"."
] | bdac586281fd3ebba4ca3a285df903f790feeee0 | https://github.com/netlogix/Netlogix.BehatCommons/blob/bdac586281fd3ebba4ca3a285df903f790feeee0/Classes/Netlogix/BehatCommons/ObjectFactory.php#L107-L118 | train |
netlogix/Netlogix.BehatCommons | Classes/Netlogix/BehatCommons/ObjectFactory.php | ObjectFactory.getNestedStructureForDottedNotation | public function getNestedStructureForDottedNotation(array $row)
{
$propertyPaths = [];
$objectStructure = [];
foreach ($row as $key => $value) {
self::applyValueProcessors($key, $value);
self::traverseObjectStructure($objectStructure, $propertyPaths, $key, $value);
}
return [$objectStructure, array_values($propertyPaths)];
} | php | public function getNestedStructureForDottedNotation(array $row)
{
$propertyPaths = [];
$objectStructure = [];
foreach ($row as $key => $value) {
self::applyValueProcessors($key, $value);
self::traverseObjectStructure($objectStructure, $propertyPaths, $key, $value);
}
return [$objectStructure, array_values($propertyPaths)];
} | [
"public",
"function",
"getNestedStructureForDottedNotation",
"(",
"array",
"$",
"row",
")",
"{",
"$",
"propertyPaths",
"=",
"[",
"]",
";",
"$",
"objectStructure",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"self",
"::",
"applyValueProcessors",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"self",
"::",
"traverseObjectStructure",
"(",
"$",
"objectStructure",
",",
"$",
"propertyPaths",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"[",
"$",
"objectStructure",
",",
"array_values",
"(",
"$",
"propertyPaths",
")",
"]",
";",
"}"
] | The input structure needs to be a key=>value map.
Every key should be a dot notation property path, every value the
corresponding value.
Example input in ".feature" file notation:
| foo -> json_encode() | ["bar"] |
| foo.2 | batz |
Example output in PHP code:
$result = ["foo" => [0 => "bar", 2: "batz"]]
The output is an array of the resulting nested array structure
and every property path contained.
@param $row
@return array | [
"The",
"input",
"structure",
"needs",
"to",
"be",
"a",
"key",
"=",
">",
"value",
"map",
".",
"Every",
"key",
"should",
"be",
"a",
"dot",
"notation",
"property",
"path",
"every",
"value",
"the",
"corresponding",
"value",
"."
] | bdac586281fd3ebba4ca3a285df903f790feeee0 | https://github.com/netlogix/Netlogix.BehatCommons/blob/bdac586281fd3ebba4ca3a285df903f790feeee0/Classes/Netlogix/BehatCommons/ObjectFactory.php#L138-L149 | train |
netlogix/Netlogix.BehatCommons | Classes/Netlogix/BehatCommons/ObjectFactory.php | ObjectFactory.rememberLastObjectAs | public function rememberLastObjectAs($identifier)
{
if (array_key_exists($identifier, $this->rememberedObjects)) {
throw new \Exception(sprintf('The identifier "%s" is already taken', $identifier), 1480605866);
}
if (!$this->startObjectTracking) {
throw new \Exception('Object tracking is not started, so remembering object is not possible.', 1480607437);
}
$object = end($this->createdObjects);
$this->rememberedObjects[$identifier] = $object;
} | php | public function rememberLastObjectAs($identifier)
{
if (array_key_exists($identifier, $this->rememberedObjects)) {
throw new \Exception(sprintf('The identifier "%s" is already taken', $identifier), 1480605866);
}
if (!$this->startObjectTracking) {
throw new \Exception('Object tracking is not started, so remembering object is not possible.', 1480607437);
}
$object = end($this->createdObjects);
$this->rememberedObjects[$identifier] = $object;
} | [
"public",
"function",
"rememberLastObjectAs",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"rememberedObjects",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The identifier \"%s\" is already taken'",
",",
"$",
"identifier",
")",
",",
"1480605866",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"startObjectTracking",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Object tracking is not started, so remembering object is not possible.'",
",",
"1480607437",
")",
";",
"}",
"$",
"object",
"=",
"end",
"(",
"$",
"this",
"->",
"createdObjects",
")",
";",
"$",
"this",
"->",
"rememberedObjects",
"[",
"$",
"identifier",
"]",
"=",
"$",
"object",
";",
"}"
] | The most recent object created gets remembered by a specific identifier
as long as the current scenario runs.
@param string $identifier
@throws \Exception | [
"The",
"most",
"recent",
"object",
"created",
"gets",
"remembered",
"by",
"a",
"specific",
"identifier",
"as",
"long",
"as",
"the",
"current",
"scenario",
"runs",
"."
] | bdac586281fd3ebba4ca3a285df903f790feeee0 | https://github.com/netlogix/Netlogix.BehatCommons/blob/bdac586281fd3ebba4ca3a285df903f790feeee0/Classes/Netlogix/BehatCommons/ObjectFactory.php#L176-L186 | train |
KDF5000/EasyThink | src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_resource.php | Smarty_Resource.config | public static function config(Smarty_Internal_Config $_config)
{
static $_incompatible_resources = array('eval' => true, 'string' => true, 'extends' => true, 'php' => true);
$config_resource = $_config->config_resource;
$smarty = $_config->smarty;
// parse resource_name
self::parseResourceName($config_resource, $smarty->default_config_type, $name, $type);
// make sure configs are not loaded via anything smarty can't handle
if (isset($_incompatible_resources[$type])) {
throw new SmartyException ("Unable to use resource '{$type}' for config");
}
// load resource handler, identify unique resource name
$resource = Smarty_Resource::load($smarty, $type);
$unique_resource_name = $resource->buildUniqueResourceName($smarty, $name);
// check runtime cache
$_cache_key = 'config|' . $unique_resource_name;
if (isset(self::$sources[$_cache_key])) {
return self::$sources[$_cache_key];
}
// create source
$source = new Smarty_Config_Source($resource, $smarty, $config_resource, $type, $name, $unique_resource_name);
$resource->populate($source, null);
// runtime cache
self::$sources[$_cache_key] = $source;
return $source;
} | php | public static function config(Smarty_Internal_Config $_config)
{
static $_incompatible_resources = array('eval' => true, 'string' => true, 'extends' => true, 'php' => true);
$config_resource = $_config->config_resource;
$smarty = $_config->smarty;
// parse resource_name
self::parseResourceName($config_resource, $smarty->default_config_type, $name, $type);
// make sure configs are not loaded via anything smarty can't handle
if (isset($_incompatible_resources[$type])) {
throw new SmartyException ("Unable to use resource '{$type}' for config");
}
// load resource handler, identify unique resource name
$resource = Smarty_Resource::load($smarty, $type);
$unique_resource_name = $resource->buildUniqueResourceName($smarty, $name);
// check runtime cache
$_cache_key = 'config|' . $unique_resource_name;
if (isset(self::$sources[$_cache_key])) {
return self::$sources[$_cache_key];
}
// create source
$source = new Smarty_Config_Source($resource, $smarty, $config_resource, $type, $name, $unique_resource_name);
$resource->populate($source, null);
// runtime cache
self::$sources[$_cache_key] = $source;
return $source;
} | [
"public",
"static",
"function",
"config",
"(",
"Smarty_Internal_Config",
"$",
"_config",
")",
"{",
"static",
"$",
"_incompatible_resources",
"=",
"array",
"(",
"'eval'",
"=>",
"true",
",",
"'string'",
"=>",
"true",
",",
"'extends'",
"=>",
"true",
",",
"'php'",
"=>",
"true",
")",
";",
"$",
"config_resource",
"=",
"$",
"_config",
"->",
"config_resource",
";",
"$",
"smarty",
"=",
"$",
"_config",
"->",
"smarty",
";",
"// parse resource_name",
"self",
"::",
"parseResourceName",
"(",
"$",
"config_resource",
",",
"$",
"smarty",
"->",
"default_config_type",
",",
"$",
"name",
",",
"$",
"type",
")",
";",
"// make sure configs are not loaded via anything smarty can't handle",
"if",
"(",
"isset",
"(",
"$",
"_incompatible_resources",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"SmartyException",
"(",
"\"Unable to use resource '{$type}' for config\"",
")",
";",
"}",
"// load resource handler, identify unique resource name",
"$",
"resource",
"=",
"Smarty_Resource",
"::",
"load",
"(",
"$",
"smarty",
",",
"$",
"type",
")",
";",
"$",
"unique_resource_name",
"=",
"$",
"resource",
"->",
"buildUniqueResourceName",
"(",
"$",
"smarty",
",",
"$",
"name",
")",
";",
"// check runtime cache",
"$",
"_cache_key",
"=",
"'config|'",
".",
"$",
"unique_resource_name",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"sources",
"[",
"$",
"_cache_key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"sources",
"[",
"$",
"_cache_key",
"]",
";",
"}",
"// create source",
"$",
"source",
"=",
"new",
"Smarty_Config_Source",
"(",
"$",
"resource",
",",
"$",
"smarty",
",",
"$",
"config_resource",
",",
"$",
"type",
",",
"$",
"name",
",",
"$",
"unique_resource_name",
")",
";",
"$",
"resource",
"->",
"populate",
"(",
"$",
"source",
",",
"null",
")",
";",
"// runtime cache",
"self",
"::",
"$",
"sources",
"[",
"$",
"_cache_key",
"]",
"=",
"$",
"source",
";",
"return",
"$",
"source",
";",
"}"
] | initialize Config Source Object for given resource
@param Smarty_Internal_Config $_config config object
@return Smarty_Config_Source Source Object | [
"initialize",
"Config",
"Source",
"Object",
"for",
"given",
"resource"
] | 86efc9c8a0d504e01e2fea55868227fdc8928841 | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_resource.php#L505-L536 | train |
phpffcms/ffcms-core | src/Managers/BootManager.php | BootManager.parseComposerLoader | private function parseComposerLoader(): void
{
// get composer autoload map
$map = $this->loader->getPrefixes();
if (Any::isArray($map)) {
// get all available apps root dirs by psr loader for apps
if (array_key_exists('Apps\\', $map)) {
foreach ($map['Apps\\'] as $appPath) {
$this->appRoots[] = $appPath;
}
}
// get Widgets map
if (array_key_exists('Widgets\\', $map)) {
// get all available root dirs by psr loader for widgets
foreach ($map['Widgets\\'] as $widgetPath) {
$this->widgetRoots[] = $widgetPath;
}
}
}
// set default root path if not found anything else
if (count($this->appRoots) < 1) {
$this->appRoots = [root];
}
if (count($this->widgetRoots) < 1) {
$this->widgetRoots = [root];
}
} | php | private function parseComposerLoader(): void
{
// get composer autoload map
$map = $this->loader->getPrefixes();
if (Any::isArray($map)) {
// get all available apps root dirs by psr loader for apps
if (array_key_exists('Apps\\', $map)) {
foreach ($map['Apps\\'] as $appPath) {
$this->appRoots[] = $appPath;
}
}
// get Widgets map
if (array_key_exists('Widgets\\', $map)) {
// get all available root dirs by psr loader for widgets
foreach ($map['Widgets\\'] as $widgetPath) {
$this->widgetRoots[] = $widgetPath;
}
}
}
// set default root path if not found anything else
if (count($this->appRoots) < 1) {
$this->appRoots = [root];
}
if (count($this->widgetRoots) < 1) {
$this->widgetRoots = [root];
}
} | [
"private",
"function",
"parseComposerLoader",
"(",
")",
":",
"void",
"{",
"// get composer autoload map",
"$",
"map",
"=",
"$",
"this",
"->",
"loader",
"->",
"getPrefixes",
"(",
")",
";",
"if",
"(",
"Any",
"::",
"isArray",
"(",
"$",
"map",
")",
")",
"{",
"// get all available apps root dirs by psr loader for apps",
"if",
"(",
"array_key_exists",
"(",
"'Apps\\\\'",
",",
"$",
"map",
")",
")",
"{",
"foreach",
"(",
"$",
"map",
"[",
"'Apps\\\\'",
"]",
"as",
"$",
"appPath",
")",
"{",
"$",
"this",
"->",
"appRoots",
"[",
"]",
"=",
"$",
"appPath",
";",
"}",
"}",
"// get Widgets map",
"if",
"(",
"array_key_exists",
"(",
"'Widgets\\\\'",
",",
"$",
"map",
")",
")",
"{",
"// get all available root dirs by psr loader for widgets",
"foreach",
"(",
"$",
"map",
"[",
"'Widgets\\\\'",
"]",
"as",
"$",
"widgetPath",
")",
"{",
"$",
"this",
"->",
"widgetRoots",
"[",
"]",
"=",
"$",
"widgetPath",
";",
"}",
"}",
"}",
"// set default root path if not found anything else",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"appRoots",
")",
"<",
"1",
")",
"{",
"$",
"this",
"->",
"appRoots",
"=",
"[",
"root",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"widgetRoots",
")",
"<",
"1",
")",
"{",
"$",
"this",
"->",
"widgetRoots",
"=",
"[",
"root",
"]",
";",
"}",
"}"
] | Find app's and widgets root directories over composer psr loader | [
"Find",
"app",
"s",
"and",
"widgets",
"root",
"directories",
"over",
"composer",
"psr",
"loader"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Managers/BootManager.php#L63-L92 | train |
phpffcms/ffcms-core | src/Managers/BootManager.php | BootManager.compileBootableClasses | public function compileBootableClasses(): void
{
// list app root's
foreach ($this->appRoots as $app) {
$app .= '/Apps/Controller/' . env_name;
$files = File::listFiles($app, ['.php'], true);
foreach ($files as $file) {
// define full class name with namespace
$class = 'Apps\Controller\\' . env_name . '\\' . Str::cleanExtension($file);
// check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof
if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Controller', true)) {
$this->objects[] = $class;
}
}
}
// list widget root's
foreach ($this->widgetRoots as $widget) {
$widget .= '/Widgets/' . env_name;
// widgets are packed in directory, classname should be the same with root directory name
$dirs = Directory::scan($widget, GLOB_ONLYDIR, true);
if (!Any::isArray($dirs)) {
continue;
}
foreach ($dirs as $instance) {
$class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance;
if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Widget', true)) {
$this->objects[] = $class;
}
}
}
} | php | public function compileBootableClasses(): void
{
// list app root's
foreach ($this->appRoots as $app) {
$app .= '/Apps/Controller/' . env_name;
$files = File::listFiles($app, ['.php'], true);
foreach ($files as $file) {
// define full class name with namespace
$class = 'Apps\Controller\\' . env_name . '\\' . Str::cleanExtension($file);
// check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof
if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Controller', true)) {
$this->objects[] = $class;
}
}
}
// list widget root's
foreach ($this->widgetRoots as $widget) {
$widget .= '/Widgets/' . env_name;
// widgets are packed in directory, classname should be the same with root directory name
$dirs = Directory::scan($widget, GLOB_ONLYDIR, true);
if (!Any::isArray($dirs)) {
continue;
}
foreach ($dirs as $instance) {
$class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance;
if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Widget', true)) {
$this->objects[] = $class;
}
}
}
} | [
"public",
"function",
"compileBootableClasses",
"(",
")",
":",
"void",
"{",
"// list app root's",
"foreach",
"(",
"$",
"this",
"->",
"appRoots",
"as",
"$",
"app",
")",
"{",
"$",
"app",
".=",
"'/Apps/Controller/'",
".",
"env_name",
";",
"$",
"files",
"=",
"File",
"::",
"listFiles",
"(",
"$",
"app",
",",
"[",
"'.php'",
"]",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// define full class name with namespace",
"$",
"class",
"=",
"'Apps\\Controller\\\\'",
".",
"env_name",
".",
"'\\\\'",
".",
"Str",
"::",
"cleanExtension",
"(",
"$",
"file",
")",
";",
"// check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"method_exists",
"(",
"$",
"class",
",",
"'boot'",
")",
"&&",
"is_a",
"(",
"$",
"class",
",",
"'Ffcms\\Core\\Arch\\Controller'",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"objects",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"}",
"}",
"// list widget root's",
"foreach",
"(",
"$",
"this",
"->",
"widgetRoots",
"as",
"$",
"widget",
")",
"{",
"$",
"widget",
".=",
"'/Widgets/'",
".",
"env_name",
";",
"// widgets are packed in directory, classname should be the same with root directory name",
"$",
"dirs",
"=",
"Directory",
"::",
"scan",
"(",
"$",
"widget",
",",
"GLOB_ONLYDIR",
",",
"true",
")",
";",
"if",
"(",
"!",
"Any",
"::",
"isArray",
"(",
"$",
"dirs",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"instance",
")",
"{",
"$",
"class",
"=",
"'Widgets\\\\'",
".",
"env_name",
".",
"'\\\\'",
".",
"$",
"instance",
".",
"'\\\\'",
".",
"$",
"instance",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"method_exists",
"(",
"$",
"class",
",",
"'boot'",
")",
"&&",
"is_a",
"(",
"$",
"class",
",",
"'Ffcms\\Core\\Arch\\Widget'",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"objects",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"}",
"}",
"}"
] | Find all bootatble instances and set it to object map
@return void | [
"Find",
"all",
"bootatble",
"instances",
"and",
"set",
"it",
"to",
"object",
"map"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Managers/BootManager.php#L98-L130 | train |
phpffcms/ffcms-core | src/Managers/BootManager.php | BootManager.run | public function run(): bool
{
$this->startMeasure(__METHOD__);
if (!Any::isArray($this->objects)) {
return false;
}
foreach ($this->objects as $class) {
forward_static_call([$class, 'boot']);
}
$this->stopMeasure(__METHOD__);
return true;
} | php | public function run(): bool
{
$this->startMeasure(__METHOD__);
if (!Any::isArray($this->objects)) {
return false;
}
foreach ($this->objects as $class) {
forward_static_call([$class, 'boot']);
}
$this->stopMeasure(__METHOD__);
return true;
} | [
"public",
"function",
"run",
"(",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"startMeasure",
"(",
"__METHOD__",
")",
";",
"if",
"(",
"!",
"Any",
"::",
"isArray",
"(",
"$",
"this",
"->",
"objects",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"class",
")",
"{",
"forward_static_call",
"(",
"[",
"$",
"class",
",",
"'boot'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"stopMeasure",
"(",
"__METHOD__",
")",
";",
"return",
"true",
";",
"}"
] | Call bootable methods in apps and widgets
@return bool | [
"Call",
"bootable",
"methods",
"in",
"apps",
"and",
"widgets"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Managers/BootManager.php#L136-L150 | train |
SahilDude89ss/PyntaxFramework | src/Pyntax/Html/Table/TableFactory.php | TableFactory.generateTable | public function generateTable(BeanInterface $bean, $findCondition = "", $returnString = false)
{
//Load the config
$this->loadConfig();
if((is_array($findCondition) && !isset($findCondition['limit'])) || empty($findCondition))
{
$recordLimitOnOnePage = $this->getConfigForElement($this->_table_config, 'recordLimitOnOnePage', $bean->getName(), 'beans');
if (empty($recordLimitOnOnePage)) {
$recordLimitOnOnePage = 10;
}
$findCondition['limit'] = $recordLimitOnOnePage;
}
$result = $bean->find($findCondition, true);
if ($returnString) {
return $this->generateTableHtml($bean, $result);
}
echo $this->generateTableHtml($bean, $result);
} | php | public function generateTable(BeanInterface $bean, $findCondition = "", $returnString = false)
{
//Load the config
$this->loadConfig();
if((is_array($findCondition) && !isset($findCondition['limit'])) || empty($findCondition))
{
$recordLimitOnOnePage = $this->getConfigForElement($this->_table_config, 'recordLimitOnOnePage', $bean->getName(), 'beans');
if (empty($recordLimitOnOnePage)) {
$recordLimitOnOnePage = 10;
}
$findCondition['limit'] = $recordLimitOnOnePage;
}
$result = $bean->find($findCondition, true);
if ($returnString) {
return $this->generateTableHtml($bean, $result);
}
echo $this->generateTableHtml($bean, $result);
} | [
"public",
"function",
"generateTable",
"(",
"BeanInterface",
"$",
"bean",
",",
"$",
"findCondition",
"=",
"\"\"",
",",
"$",
"returnString",
"=",
"false",
")",
"{",
"//Load the config",
"$",
"this",
"->",
"loadConfig",
"(",
")",
";",
"if",
"(",
"(",
"is_array",
"(",
"$",
"findCondition",
")",
"&&",
"!",
"isset",
"(",
"$",
"findCondition",
"[",
"'limit'",
"]",
")",
")",
"||",
"empty",
"(",
"$",
"findCondition",
")",
")",
"{",
"$",
"recordLimitOnOnePage",
"=",
"$",
"this",
"->",
"getConfigForElement",
"(",
"$",
"this",
"->",
"_table_config",
",",
"'recordLimitOnOnePage'",
",",
"$",
"bean",
"->",
"getName",
"(",
")",
",",
"'beans'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"recordLimitOnOnePage",
")",
")",
"{",
"$",
"recordLimitOnOnePage",
"=",
"10",
";",
"}",
"$",
"findCondition",
"[",
"'limit'",
"]",
"=",
"$",
"recordLimitOnOnePage",
";",
"}",
"$",
"result",
"=",
"$",
"bean",
"->",
"find",
"(",
"$",
"findCondition",
",",
"true",
")",
";",
"if",
"(",
"$",
"returnString",
")",
"{",
"return",
"$",
"this",
"->",
"generateTableHtml",
"(",
"$",
"bean",
",",
"$",
"result",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"generateTableHtml",
"(",
"$",
"bean",
",",
"$",
"result",
")",
";",
"}"
] | This function generates the table with the Bean and findCondition is passed.
@param BeanInterface $bean
@param string $findCondition
@param bool|false $returnString
@return string | [
"This",
"function",
"generates",
"the",
"table",
"with",
"the",
"Bean",
"and",
"findCondition",
"is",
"passed",
"."
] | 045cca87d24eb2b6405734966c64344e00224c7b | https://github.com/SahilDude89ss/PyntaxFramework/blob/045cca87d24eb2b6405734966c64344e00224c7b/src/Pyntax/Html/Table/TableFactory.php#L49-L70 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.Area | protected function Area()
{
if (!$this->area) {
$this->area = new Area(Request::GetData('area'));
}
return $this->area;
} | php | protected function Area()
{
if (!$this->area) {
$this->area = new Area(Request::GetData('area'));
}
return $this->area;
} | [
"protected",
"function",
"Area",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"area",
")",
"{",
"$",
"this",
"->",
"area",
"=",
"new",
"Area",
"(",
"Request",
"::",
"GetData",
"(",
"'area'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"area",
";",
"}"
] | The area from request
@return Area | [
"The",
"area",
"from",
"request"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L135-L141 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.Container | protected function Container()
{
if (!$this->container) {
$this->container = new Container(Request::GetData('container'));
}
return $this->container;
} | php | protected function Container()
{
if (!$this->container) {
$this->container = new Container(Request::GetData('container'));
}
return $this->container;
} | [
"protected",
"function",
"Container",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
")",
"{",
"$",
"this",
"->",
"container",
"=",
"new",
"Container",
"(",
"Request",
"::",
"GetData",
"(",
"'container'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
";",
"}"
] | The container from request
@return Container | [
"The",
"container",
"from",
"request"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L153-L159 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.Page | protected function Page()
{
if (!$this->page) {
$this->page = new Page(Request::GetData('page'));
}
return $this->page;
} | php | protected function Page()
{
if (!$this->page) {
$this->page = new Page(Request::GetData('page'));
}
return $this->page;
} | [
"protected",
"function",
"Page",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"page",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"new",
"Page",
"(",
"Request",
"::",
"GetData",
"(",
"'page'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"page",
";",
"}"
] | The page from request
@return Page | [
"The",
"page",
"from",
"request"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L171-L177 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.ParentItem | private function ParentItem()
{
$this->parent = $this->GetTreeItem('parent');
return $this->parent->Exists() ? $this->parent : null;
} | php | private function ParentItem()
{
$this->parent = $this->GetTreeItem('parent');
return $this->parent->Exists() ? $this->parent : null;
} | [
"private",
"function",
"ParentItem",
"(",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"$",
"this",
"->",
"GetTreeItem",
"(",
"'parent'",
")",
";",
"return",
"$",
"this",
"->",
"parent",
"->",
"Exists",
"(",
")",
"?",
"$",
"this",
"->",
"parent",
":",
"null",
";",
"}"
] | Gets the parent tree item
@return TableObject Returns either the related page or the layout content | [
"Gets",
"the",
"parent",
"tree",
"item"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L185-L189 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.PreviousItem | private function PreviousItem()
{
$this->previous = $this->GetTreeItem('previous');
return $this->previous->Exists() ? $this->previous : null;
} | php | private function PreviousItem()
{
$this->previous = $this->GetTreeItem('previous');
return $this->previous->Exists() ? $this->previous : null;
} | [
"private",
"function",
"PreviousItem",
"(",
")",
"{",
"$",
"this",
"->",
"previous",
"=",
"$",
"this",
"->",
"GetTreeItem",
"(",
"'previous'",
")",
";",
"return",
"$",
"this",
"->",
"previous",
"->",
"Exists",
"(",
")",
"?",
"$",
"this",
"->",
"previous",
":",
"null",
";",
"}"
] | The previous item
@return TemplateObject | [
"The",
"previous",
"item"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L219-L223 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.Location | protected function Location()
{
if ($this->Container()->Exists()) {
return Enums\ContentLocation::Container();
}
else if ($this->Area()->Exists()) {
if ($this->Page()->Exists()) {
return Enums\ContentLocation::Page();
}
return Enums\ContentLocation::Layout();
}
return null;
} | php | protected function Location()
{
if ($this->Container()->Exists()) {
return Enums\ContentLocation::Container();
}
else if ($this->Area()->Exists()) {
if ($this->Page()->Exists()) {
return Enums\ContentLocation::Page();
}
return Enums\ContentLocation::Layout();
}
return null;
} | [
"protected",
"function",
"Location",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Container",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"return",
"Enums",
"\\",
"ContentLocation",
"::",
"Container",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"Area",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Page",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"return",
"Enums",
"\\",
"ContentLocation",
"::",
"Page",
"(",
")",
";",
"}",
"return",
"Enums",
"\\",
"ContentLocation",
"::",
"Layout",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Gets the content location
@return Enums\ContentLocation | [
"Gets",
"the",
"content",
"location"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L229-L241 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.InitContentRights | private function InitContentRights()
{
$beContentRights = null;
if ($this->Content()->Exists()) {
$beContentRights = $this->Content()->GetUserGroupRights();
}
$this->contentRights = new ContentRights($this->FindParentRights(), $beContentRights);
} | php | private function InitContentRights()
{
$beContentRights = null;
if ($this->Content()->Exists()) {
$beContentRights = $this->Content()->GetUserGroupRights();
}
$this->contentRights = new ContentRights($this->FindParentRights(), $beContentRights);
} | [
"private",
"function",
"InitContentRights",
"(",
")",
"{",
"$",
"beContentRights",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"$",
"beContentRights",
"=",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetUserGroupRights",
"(",
")",
";",
"}",
"$",
"this",
"->",
"contentRights",
"=",
"new",
"ContentRights",
"(",
"$",
"this",
"->",
"FindParentRights",
"(",
")",
",",
"$",
"beContentRights",
")",
";",
"}"
] | Initialize the content rights snippet | [
"Initialize",
"the",
"content",
"rights",
"snippet"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L274-L281 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.FindParentRights | private function FindParentRights()
{
$parentRights = null;
$parentContent = $this->Content()->Exists() ? ContentTreeUtil::ParentOf($this->Content()) : null;
if ($parentContent) {
$parentRights = RightsFinder::FindContentRights($parentContent);
}
if (!$parentRights) {
switch ($this->Location()) {
case Enums\ContentLocation::Page():
$pageRights = RightsFinder::FindPageRights($this->Page());
$parentRights = $pageRights ? $pageRights->GetContentRights() : null;
break;
case Enums\ContentLocation::Layout():
$layoutRights = $this->Area()->GetLayout()->GetUserGroupRights();
$parentRights = $layoutRights ? $layoutRights->GetContentRights() : null;
break;
case Enums\ContentLocation::Container():
$containerRights = $this->Container()->GetUserGroupRights();
$parentRights = $containerRights ? $containerRights->GetContentRights() : null;
break;
}
}
return $parentRights;
} | php | private function FindParentRights()
{
$parentRights = null;
$parentContent = $this->Content()->Exists() ? ContentTreeUtil::ParentOf($this->Content()) : null;
if ($parentContent) {
$parentRights = RightsFinder::FindContentRights($parentContent);
}
if (!$parentRights) {
switch ($this->Location()) {
case Enums\ContentLocation::Page():
$pageRights = RightsFinder::FindPageRights($this->Page());
$parentRights = $pageRights ? $pageRights->GetContentRights() : null;
break;
case Enums\ContentLocation::Layout():
$layoutRights = $this->Area()->GetLayout()->GetUserGroupRights();
$parentRights = $layoutRights ? $layoutRights->GetContentRights() : null;
break;
case Enums\ContentLocation::Container():
$containerRights = $this->Container()->GetUserGroupRights();
$parentRights = $containerRights ? $containerRights->GetContentRights() : null;
break;
}
}
return $parentRights;
} | [
"private",
"function",
"FindParentRights",
"(",
")",
"{",
"$",
"parentRights",
"=",
"null",
";",
"$",
"parentContent",
"=",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Exists",
"(",
")",
"?",
"ContentTreeUtil",
"::",
"ParentOf",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
")",
":",
"null",
";",
"if",
"(",
"$",
"parentContent",
")",
"{",
"$",
"parentRights",
"=",
"RightsFinder",
"::",
"FindContentRights",
"(",
"$",
"parentContent",
")",
";",
"}",
"if",
"(",
"!",
"$",
"parentRights",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"Location",
"(",
")",
")",
"{",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Page",
"(",
")",
":",
"$",
"pageRights",
"=",
"RightsFinder",
"::",
"FindPageRights",
"(",
"$",
"this",
"->",
"Page",
"(",
")",
")",
";",
"$",
"parentRights",
"=",
"$",
"pageRights",
"?",
"$",
"pageRights",
"->",
"GetContentRights",
"(",
")",
":",
"null",
";",
"break",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Layout",
"(",
")",
":",
"$",
"layoutRights",
"=",
"$",
"this",
"->",
"Area",
"(",
")",
"->",
"GetLayout",
"(",
")",
"->",
"GetUserGroupRights",
"(",
")",
";",
"$",
"parentRights",
"=",
"$",
"layoutRights",
"?",
"$",
"layoutRights",
"->",
"GetContentRights",
"(",
")",
":",
"null",
";",
"break",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Container",
"(",
")",
":",
"$",
"containerRights",
"=",
"$",
"this",
"->",
"Container",
"(",
")",
"->",
"GetUserGroupRights",
"(",
")",
";",
"$",
"parentRights",
"=",
"$",
"containerRights",
"?",
"$",
"containerRights",
"->",
"GetContentRights",
"(",
")",
":",
"null",
";",
"break",
";",
"}",
"}",
"return",
"$",
"parentRights",
";",
"}"
] | Finds the parent rights
@return BackendContentRights | [
"Finds",
"the",
"parent",
"rights"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L316-L342 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.RenderGroupRights | protected function RenderGroupRights()
{
if (!$this->CanAssignGroup()) {
return '';
}
$result = $this->RenderElement('UserGroup');
return $result . '<div id="group-rights">' . $this->contentRights->Render() . '</div>';
} | php | protected function RenderGroupRights()
{
if (!$this->CanAssignGroup()) {
return '';
}
$result = $this->RenderElement('UserGroup');
return $result . '<div id="group-rights">' . $this->contentRights->Render() . '</div>';
} | [
"protected",
"function",
"RenderGroupRights",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"CanAssignGroup",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"RenderElement",
"(",
"'UserGroup'",
")",
";",
"return",
"$",
"result",
".",
"'<div id=\"group-rights\">'",
".",
"$",
"this",
"->",
"contentRights",
"->",
"Render",
"(",
")",
".",
"'</div>'",
";",
"}"
] | Renders the group rights
@return string | [
"Renders",
"the",
"group",
"rights"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L348-L355 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AddGuestsOnlyField | private function AddGuestsOnlyField()
{
$field = new Checkbox('GuestsOnly', '1', (bool) $this->Content()->GetGuestsOnly());
$this->AddField($field, false, Trans('Core.ContentForm.GuestsOnly'));
} | php | private function AddGuestsOnlyField()
{
$field = new Checkbox('GuestsOnly', '1', (bool) $this->Content()->GetGuestsOnly());
$this->AddField($field, false, Trans('Core.ContentForm.GuestsOnly'));
} | [
"private",
"function",
"AddGuestsOnlyField",
"(",
")",
"{",
"$",
"field",
"=",
"new",
"Checkbox",
"(",
"'GuestsOnly'",
",",
"'1'",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetGuestsOnly",
"(",
")",
")",
";",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
",",
"false",
",",
"Trans",
"(",
"'Core.ContentForm.GuestsOnly'",
")",
")",
";",
"}"
] | Adds the checkbox for "guests only" visibility of a content | [
"Adds",
"the",
"checkbox",
"for",
"guests",
"only",
"visibility",
"of",
"a",
"content"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L418-L422 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.LoadElement | protected function LoadElement()
{
if ($this->Content()->Exists()) {
return $this->ElementSchema()->ByContent($this->Content());
}
return $this->ElementSchema()->CreateInstance();
} | php | protected function LoadElement()
{
if ($this->Content()->Exists()) {
return $this->ElementSchema()->ByContent($this->Content());
}
return $this->ElementSchema()->CreateInstance();
} | [
"protected",
"function",
"LoadElement",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ElementSchema",
"(",
")",
"->",
"ByContent",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"ElementSchema",
"(",
")",
"->",
"CreateInstance",
"(",
")",
";",
"}"
] | Helper function to retrieve the content element from database
@return TableObject Returns the content element by content if given | [
"Helper",
"function",
"to",
"retrieve",
"the",
"content",
"element",
"from",
"database"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L428-L434 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.SaveContent | private function SaveContent()
{
$this->Content()->SetType($this->FrontendModule()->MyType());
$this->Content()->SetCssClass($this->Value('CssClass'));
$this->Content()->SetCssID($this->Value('CssID'));
$this->Content()->SetTemplate($this->Value('Template'));
$this->Content()->SetCacheLifetime((int) $this->Value('CacheLifetime'));
$this->Content()->SetGuestsOnly((bool) $this->Value('GuestsOnly'));
if ($this->AutoPublish())
{
$this->Content()->SetPublish(true);
}
else
{
$this->Content()->SetPublish((bool) $this->Value('Publish'));
}
$this->Content()->SetPublishFrom($this->PublishDate('PublishFrom'));
$this->Content()->SetPublishTo($this->PublishDate('PublishTo'));
$action = Action::Update();
if (!$this->Content()->Exists()) {
$action = Action::Create();
$this->Content()->SetUser(self::Guard()->GetUser());
}
$this->Content()->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportContentAction($this->Content(), $action);
if ($this->CanAssignGroup()) {
$this->SaveRights();
}
$this->SaveMemberGroups();
$this->SaveWordings();
} | php | private function SaveContent()
{
$this->Content()->SetType($this->FrontendModule()->MyType());
$this->Content()->SetCssClass($this->Value('CssClass'));
$this->Content()->SetCssID($this->Value('CssID'));
$this->Content()->SetTemplate($this->Value('Template'));
$this->Content()->SetCacheLifetime((int) $this->Value('CacheLifetime'));
$this->Content()->SetGuestsOnly((bool) $this->Value('GuestsOnly'));
if ($this->AutoPublish())
{
$this->Content()->SetPublish(true);
}
else
{
$this->Content()->SetPublish((bool) $this->Value('Publish'));
}
$this->Content()->SetPublishFrom($this->PublishDate('PublishFrom'));
$this->Content()->SetPublishTo($this->PublishDate('PublishTo'));
$action = Action::Update();
if (!$this->Content()->Exists()) {
$action = Action::Create();
$this->Content()->SetUser(self::Guard()->GetUser());
}
$this->Content()->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportContentAction($this->Content(), $action);
if ($this->CanAssignGroup()) {
$this->SaveRights();
}
$this->SaveMemberGroups();
$this->SaveWordings();
} | [
"private",
"function",
"SaveContent",
"(",
")",
"{",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetType",
"(",
"$",
"this",
"->",
"FrontendModule",
"(",
")",
"->",
"MyType",
"(",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetCssClass",
"(",
"$",
"this",
"->",
"Value",
"(",
"'CssClass'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetCssID",
"(",
"$",
"this",
"->",
"Value",
"(",
"'CssID'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetTemplate",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Template'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetCacheLifetime",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"Value",
"(",
"'CacheLifetime'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetGuestsOnly",
"(",
"(",
"bool",
")",
"$",
"this",
"->",
"Value",
"(",
"'GuestsOnly'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"AutoPublish",
"(",
")",
")",
"{",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetPublish",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetPublish",
"(",
"(",
"bool",
")",
"$",
"this",
"->",
"Value",
"(",
"'Publish'",
")",
")",
";",
"}",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetPublishFrom",
"(",
"$",
"this",
"->",
"PublishDate",
"(",
"'PublishFrom'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetPublishTo",
"(",
"$",
"this",
"->",
"PublishDate",
"(",
"'PublishTo'",
")",
")",
";",
"$",
"action",
"=",
"Action",
"::",
"Update",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"$",
"action",
"=",
"Action",
"::",
"Create",
"(",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetUser",
"(",
"self",
"::",
"Guard",
"(",
")",
"->",
"GetUser",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Save",
"(",
")",
";",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"self",
"::",
"Guard",
"(",
")",
"->",
"GetUser",
"(",
")",
")",
";",
"$",
"logger",
"->",
"ReportContentAction",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
",",
"$",
"action",
")",
";",
"if",
"(",
"$",
"this",
"->",
"CanAssignGroup",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SaveRights",
"(",
")",
";",
"}",
"$",
"this",
"->",
"SaveMemberGroups",
"(",
")",
";",
"$",
"this",
"->",
"SaveWordings",
"(",
")",
";",
"}"
] | Saves content base properties | [
"Saves",
"content",
"base",
"properties"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L465-L497 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.PublishDate | private function PublishDate($baseName)
{
if (!$this->Content()->GetPublish()) {
return null;
}
$strDate = $this->Value($baseName . 'Date');
if (!$strDate) {
return null;
}
$date = \DateTime::createFromFormat($this->dateFormat, $strDate);
$date->setTime((int) $this->Value($baseName . 'Hour'), (int) $this->Value($baseName . 'Minute'), 0);
return Date::FromDateTime($date);
} | php | private function PublishDate($baseName)
{
if (!$this->Content()->GetPublish()) {
return null;
}
$strDate = $this->Value($baseName . 'Date');
if (!$strDate) {
return null;
}
$date = \DateTime::createFromFormat($this->dateFormat, $strDate);
$date->setTime((int) $this->Value($baseName . 'Hour'), (int) $this->Value($baseName . 'Minute'), 0);
return Date::FromDateTime($date);
} | [
"private",
"function",
"PublishDate",
"(",
"$",
"baseName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetPublish",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"strDate",
"=",
"$",
"this",
"->",
"Value",
"(",
"$",
"baseName",
".",
"'Date'",
")",
";",
"if",
"(",
"!",
"$",
"strDate",
")",
"{",
"return",
"null",
";",
"}",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"this",
"->",
"dateFormat",
",",
"$",
"strDate",
")",
";",
"$",
"date",
"->",
"setTime",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"Value",
"(",
"$",
"baseName",
".",
"'Hour'",
")",
",",
"(",
"int",
")",
"$",
"this",
"->",
"Value",
"(",
"$",
"baseName",
".",
"'Minute'",
")",
",",
"0",
")",
";",
"return",
"Date",
"::",
"FromDateTime",
"(",
"$",
"date",
")",
";",
"}"
] | Gets a publishing date
@param string $baseName The base name; 'PublishFrom' or 'PublishTo'
@return Date Returns the date | [
"Gets",
"a",
"publishing",
"date"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L515-L527 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.SaveRights | private function SaveRights()
{
$userGroup = Usergroup::Schema()->ByID($this->Value('UserGroup'));
$this->Content()->SetUserGroup($userGroup);
if (!$userGroup) {
$oldRights = $this->Content()->GetUserGroupRights();
if ($oldRights) {
$oldRights->Delete();
}
$this->Content()->SetUserGroupRights(null);
}
else {
$this->contentRights->Save();
$this->Content()->SetUserGroupRights($this->contentRights->Rights());
}
$this->Content()->Save();
} | php | private function SaveRights()
{
$userGroup = Usergroup::Schema()->ByID($this->Value('UserGroup'));
$this->Content()->SetUserGroup($userGroup);
if (!$userGroup) {
$oldRights = $this->Content()->GetUserGroupRights();
if ($oldRights) {
$oldRights->Delete();
}
$this->Content()->SetUserGroupRights(null);
}
else {
$this->contentRights->Save();
$this->Content()->SetUserGroupRights($this->contentRights->Rights());
}
$this->Content()->Save();
} | [
"private",
"function",
"SaveRights",
"(",
")",
"{",
"$",
"userGroup",
"=",
"Usergroup",
"::",
"Schema",
"(",
")",
"->",
"ByID",
"(",
"$",
"this",
"->",
"Value",
"(",
"'UserGroup'",
")",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetUserGroup",
"(",
"$",
"userGroup",
")",
";",
"if",
"(",
"!",
"$",
"userGroup",
")",
"{",
"$",
"oldRights",
"=",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetUserGroupRights",
"(",
")",
";",
"if",
"(",
"$",
"oldRights",
")",
"{",
"$",
"oldRights",
"->",
"Delete",
"(",
")",
";",
"}",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetUserGroupRights",
"(",
"null",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contentRights",
"->",
"Save",
"(",
")",
";",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"SetUserGroupRights",
"(",
"$",
"this",
"->",
"contentRights",
"->",
"Rights",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Save",
"(",
")",
";",
"}"
] | Saves the content rights and user group | [
"Saves",
"the",
"content",
"rights",
"and",
"user",
"group"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L561-L577 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AttachContent | private function AttachContent($isNew)
{
switch ($this->Location()) {
case Enums\ContentLocation::Layout():
$this->AttachLayoutContent($isNew);
break;
case Enums\ContentLocation::Page():
$this->AttachPageContent($isNew);
break;
case Enums\ContentLocation::Container():
$this->AttachContainerContent($isNew);
break;
}
} | php | private function AttachContent($isNew)
{
switch ($this->Location()) {
case Enums\ContentLocation::Layout():
$this->AttachLayoutContent($isNew);
break;
case Enums\ContentLocation::Page():
$this->AttachPageContent($isNew);
break;
case Enums\ContentLocation::Container():
$this->AttachContainerContent($isNew);
break;
}
} | [
"private",
"function",
"AttachContent",
"(",
"$",
"isNew",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"Location",
"(",
")",
")",
"{",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Layout",
"(",
")",
":",
"$",
"this",
"->",
"AttachLayoutContent",
"(",
"$",
"isNew",
")",
";",
"break",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Page",
"(",
")",
":",
"$",
"this",
"->",
"AttachPageContent",
"(",
"$",
"isNew",
")",
";",
"break",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Container",
"(",
")",
":",
"$",
"this",
"->",
"AttachContainerContent",
"(",
"$",
"isNew",
")",
";",
"break",
";",
"}",
"}"
] | Attaches content to tree item
@param boolean $isNew True if content is new | [
"Attaches",
"content",
"to",
"tree",
"item"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L591-L607 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AttachContainerContent | private function AttachContainerContent($isNew)
{
$provider = new ContainerContentTreeProvider($this->Container());
$tree = new TreeBuilder($provider);
$containerContent = $this->Content()->GetContainerContent();
if (!$containerContent) {
$containerContent = new ContainerContent();
$containerContent->SetContainer($this->Container());
$provider->AttachContent($containerContent, $this->Content());
}
if ($isNew) {
$tree->Insert($containerContent, $this->ParentItem(), $this->PreviousItem());
}
} | php | private function AttachContainerContent($isNew)
{
$provider = new ContainerContentTreeProvider($this->Container());
$tree = new TreeBuilder($provider);
$containerContent = $this->Content()->GetContainerContent();
if (!$containerContent) {
$containerContent = new ContainerContent();
$containerContent->SetContainer($this->Container());
$provider->AttachContent($containerContent, $this->Content());
}
if ($isNew) {
$tree->Insert($containerContent, $this->ParentItem(), $this->PreviousItem());
}
} | [
"private",
"function",
"AttachContainerContent",
"(",
"$",
"isNew",
")",
"{",
"$",
"provider",
"=",
"new",
"ContainerContentTreeProvider",
"(",
"$",
"this",
"->",
"Container",
"(",
")",
")",
";",
"$",
"tree",
"=",
"new",
"TreeBuilder",
"(",
"$",
"provider",
")",
";",
"$",
"containerContent",
"=",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetContainerContent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"containerContent",
")",
"{",
"$",
"containerContent",
"=",
"new",
"ContainerContent",
"(",
")",
";",
"$",
"containerContent",
"->",
"SetContainer",
"(",
"$",
"this",
"->",
"Container",
"(",
")",
")",
";",
"$",
"provider",
"->",
"AttachContent",
"(",
"$",
"containerContent",
",",
"$",
"this",
"->",
"Content",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"isNew",
")",
"{",
"$",
"tree",
"->",
"Insert",
"(",
"$",
"containerContent",
",",
"$",
"this",
"->",
"ParentItem",
"(",
")",
",",
"$",
"this",
"->",
"PreviousItem",
"(",
")",
")",
";",
"}",
"}"
] | Attaches the content to the container
@param boolean $isNew | [
"Attaches",
"the",
"content",
"to",
"the",
"container"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L645-L658 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AddCssIDField | protected final function AddCssIDField()
{
$name = 'CssID';
$this->AddField(Input::Text($name, $this->Content()->GetCssID()), false, Trans("Core.ContentForm.$name"));
} | php | protected final function AddCssIDField()
{
$name = 'CssID';
$this->AddField(Input::Text($name, $this->Content()->GetCssID()), false, Trans("Core.ContentForm.$name"));
} | [
"protected",
"final",
"function",
"AddCssIDField",
"(",
")",
"{",
"$",
"name",
"=",
"'CssID'",
";",
"$",
"this",
"->",
"AddField",
"(",
"Input",
"::",
"Text",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetCssID",
"(",
")",
")",
",",
"false",
",",
"Trans",
"(",
"\"Core.ContentForm.$name\"",
")",
")",
";",
"}"
] | Adds the css id form field | [
"Adds",
"the",
"css",
"id",
"form",
"field"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L672-L676 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AddCacheLifetimeField | protected function AddCacheLifetimeField()
{
$name = 'CacheLifetime';
$label = "Core.ContentForm.$name";
$field = Input::Text($name, (string) (int) $this->Content()->GetCacheLifetime());
$this->AddField($field, false, Trans($label));
$this->AddValidator($name, Integer::PositiveOrNull(), $label . '.');
} | php | protected function AddCacheLifetimeField()
{
$name = 'CacheLifetime';
$label = "Core.ContentForm.$name";
$field = Input::Text($name, (string) (int) $this->Content()->GetCacheLifetime());
$this->AddField($field, false, Trans($label));
$this->AddValidator($name, Integer::PositiveOrNull(), $label . '.');
} | [
"protected",
"function",
"AddCacheLifetimeField",
"(",
")",
"{",
"$",
"name",
"=",
"'CacheLifetime'",
";",
"$",
"label",
"=",
"\"Core.ContentForm.$name\"",
";",
"$",
"field",
"=",
"Input",
"::",
"Text",
"(",
"$",
"name",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetCacheLifetime",
"(",
")",
")",
";",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
",",
"false",
",",
"Trans",
"(",
"$",
"label",
")",
")",
";",
"$",
"this",
"->",
"AddValidator",
"(",
"$",
"name",
",",
"Integer",
"::",
"PositiveOrNull",
"(",
")",
",",
"$",
"label",
".",
"'.'",
")",
";",
"}"
] | Adds the lifetime field | [
"Adds",
"the",
"lifetime",
"field"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L753-L760 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AddTemplateField | protected final function AddTemplateField()
{
$name = 'Template';
$field = new Select($name, (string) $this->Content()->GetTemplate());
$field->AddOption('', Trans("Core.ContentForm.$name.Default"));
$folder = PathUtil::ModuleCustomTemplatesFolder($this->FrontendModule());
if (Folder::Exists($folder)) {
$files = Folder::GetFiles($folder);
foreach ($files as $file) {
$value = Path::FilenameNoExtension($file);
$field->AddOption($value, $value);
}
}
$this->AddField($field, false, Trans("Core.ContentForm.$name"));
} | php | protected final function AddTemplateField()
{
$name = 'Template';
$field = new Select($name, (string) $this->Content()->GetTemplate());
$field->AddOption('', Trans("Core.ContentForm.$name.Default"));
$folder = PathUtil::ModuleCustomTemplatesFolder($this->FrontendModule());
if (Folder::Exists($folder)) {
$files = Folder::GetFiles($folder);
foreach ($files as $file) {
$value = Path::FilenameNoExtension($file);
$field->AddOption($value, $value);
}
}
$this->AddField($field, false, Trans("Core.ContentForm.$name"));
} | [
"protected",
"final",
"function",
"AddTemplateField",
"(",
")",
"{",
"$",
"name",
"=",
"'Template'",
";",
"$",
"field",
"=",
"new",
"Select",
"(",
"$",
"name",
",",
"(",
"string",
")",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetTemplate",
"(",
")",
")",
";",
"$",
"field",
"->",
"AddOption",
"(",
"''",
",",
"Trans",
"(",
"\"Core.ContentForm.$name.Default\"",
")",
")",
";",
"$",
"folder",
"=",
"PathUtil",
"::",
"ModuleCustomTemplatesFolder",
"(",
"$",
"this",
"->",
"FrontendModule",
"(",
")",
")",
";",
"if",
"(",
"Folder",
"::",
"Exists",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"files",
"=",
"Folder",
"::",
"GetFiles",
"(",
"$",
"folder",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"value",
"=",
"Path",
"::",
"FilenameNoExtension",
"(",
"$",
"file",
")",
";",
"$",
"field",
"->",
"AddOption",
"(",
"$",
"value",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
",",
"false",
",",
"Trans",
"(",
"\"Core.ContentForm.$name\"",
")",
")",
";",
"}"
] | Adds the template select field
@param FrontendModule $module The module for template selection | [
"Adds",
"the",
"template",
"select",
"field"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L766-L781 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.BackLink | protected function BackLink()
{
$selected = $this->SelectedTreeID();
switch ($this->Location()) {
case Enums\ContentLocation::Page():
return $this->PageBackLink($selected);
case Enums\ContentLocation::Layout():
return $this->LayoutBackLink($selected);
case Enums\ContentLocation::Container():
return $this->ContainerBackLink($selected);
}
} | php | protected function BackLink()
{
$selected = $this->SelectedTreeID();
switch ($this->Location()) {
case Enums\ContentLocation::Page():
return $this->PageBackLink($selected);
case Enums\ContentLocation::Layout():
return $this->LayoutBackLink($selected);
case Enums\ContentLocation::Container():
return $this->ContainerBackLink($selected);
}
} | [
"protected",
"function",
"BackLink",
"(",
")",
"{",
"$",
"selected",
"=",
"$",
"this",
"->",
"SelectedTreeID",
"(",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"Location",
"(",
")",
")",
"{",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Page",
"(",
")",
":",
"return",
"$",
"this",
"->",
"PageBackLink",
"(",
"$",
"selected",
")",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Layout",
"(",
")",
":",
"return",
"$",
"this",
"->",
"LayoutBackLink",
"(",
"$",
"selected",
")",
";",
"case",
"Enums",
"\\",
"ContentLocation",
"::",
"Container",
"(",
")",
":",
"return",
"$",
"this",
"->",
"ContainerBackLink",
"(",
"$",
"selected",
")",
";",
"}",
"}"
] | The back link url
@return string | [
"The",
"back",
"link",
"url"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L819-L832 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.AddWordingFields | private function AddWordingFields()
{
foreach ($this->Wordings() as $name) {
$wording = $this->FindWording($name);
$fieldName = $this->WordingFieldName($name);
$field = Input::Text($fieldName, $wording ? $wording->GetText() : '');
$field->SetHtmlAttribute('placeholder', Trans('Core.ContentForm.Wording.Placeholder'));
$this->AddField($field);
}
} | php | private function AddWordingFields()
{
foreach ($this->Wordings() as $name) {
$wording = $this->FindWording($name);
$fieldName = $this->WordingFieldName($name);
$field = Input::Text($fieldName, $wording ? $wording->GetText() : '');
$field->SetHtmlAttribute('placeholder', Trans('Core.ContentForm.Wording.Placeholder'));
$this->AddField($field);
}
} | [
"private",
"function",
"AddWordingFields",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"Wordings",
"(",
")",
"as",
"$",
"name",
")",
"{",
"$",
"wording",
"=",
"$",
"this",
"->",
"FindWording",
"(",
"$",
"name",
")",
";",
"$",
"fieldName",
"=",
"$",
"this",
"->",
"WordingFieldName",
"(",
"$",
"name",
")",
";",
"$",
"field",
"=",
"Input",
"::",
"Text",
"(",
"$",
"fieldName",
",",
"$",
"wording",
"?",
"$",
"wording",
"->",
"GetText",
"(",
")",
":",
"''",
")",
";",
"$",
"field",
"->",
"SetHtmlAttribute",
"(",
"'placeholder'",
",",
"Trans",
"(",
"'Core.ContentForm.Wording.Placeholder'",
")",
")",
";",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
")",
";",
"}",
"}"
] | Adds the wording fields | [
"Adds",
"the",
"wording",
"fields"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L868-L877 | train |
agentmedia/phine-core | src/Core/Logic/Module/ContentForm.php | ContentForm.FindWording | private function FindWording($name)
{
if (!$this->Content()->Exists()) {
return null;
}
$sql = Access::SqlBuilder();
$tblWording = ContentWording::Schema()->Table();
$where = $sql->Equals($tblWording->Field('Content'), $sql->Value($this->Content()->GetID()))
->And_($sql->Equals($tblWording->Field('Placeholder'), $sql->Value($name)));
return ContentWording::Schema()->First($where);
} | php | private function FindWording($name)
{
if (!$this->Content()->Exists()) {
return null;
}
$sql = Access::SqlBuilder();
$tblWording = ContentWording::Schema()->Table();
$where = $sql->Equals($tblWording->Field('Content'), $sql->Value($this->Content()->GetID()))
->And_($sql->Equals($tblWording->Field('Placeholder'), $sql->Value($name)));
return ContentWording::Schema()->First($where);
} | [
"private",
"function",
"FindWording",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"Exists",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"tblWording",
"=",
"ContentWording",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblWording",
"->",
"Field",
"(",
"'Content'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"this",
"->",
"Content",
"(",
")",
"->",
"GetID",
"(",
")",
")",
")",
"->",
"And_",
"(",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblWording",
"->",
"Field",
"(",
"'Placeholder'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"name",
")",
")",
")",
";",
"return",
"ContentWording",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
")",
";",
"}"
] | Finds the wording with the given placeholder name
@param string $name The placeholder name
@return ContentWording Gets the matching content wording | [
"Finds",
"the",
"wording",
"with",
"the",
"given",
"placeholder",
"name"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ContentForm.php#L935-L946 | train |
jenskooij/cloudcontrol | src/images/BitmapFactory.php | BitmapFactory.loopThroughBodyAndCalculatePixels | private static function loopThroughBodyAndCalculatePixels(BitmapBodyModel $bitmapBodyModel)
{
for ($i = 0; $i < $bitmapBodyModel->bodySize; $i += 3) {
// Calculate line-ending and padding
if ($bitmapBodyModel->x >= $bitmapBodyModel->width) {
// If padding needed, ignore image-padding. Shift i to the ending of the current 32-bit-block
if ($bitmapBodyModel->usePadding) {
$i += $bitmapBodyModel->width % 4;
}
// Reset horizontal position
$bitmapBodyModel->x = 0;
// Raise the height-position (bottom-up)
$bitmapBodyModel->y++;
// Reached the image-height? Break the for-loop
if ($bitmapBodyModel->y > $bitmapBodyModel->height) {
break;
}
}
// Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body
$iPos = $i * 2;
$r = hexdec($bitmapBodyModel->body[$iPos + 4] . $bitmapBodyModel->body[$iPos + 5]);
$g = hexdec($bitmapBodyModel->body[$iPos + 2] . $bitmapBodyModel->body[$iPos + 3]);
$b = hexdec($bitmapBodyModel->body[$iPos] . $bitmapBodyModel->body[$iPos + 1]);
// Calculate and draw the pixel
$color = imagecolorallocate($bitmapBodyModel->image, (int)$r, (int)$g, (int)$b);
imagesetpixel($bitmapBodyModel->image, $bitmapBodyModel->x, $bitmapBodyModel->height - $bitmapBodyModel->y, $color);
// Raise the horizontal position
$bitmapBodyModel->x++;
}
} | php | private static function loopThroughBodyAndCalculatePixels(BitmapBodyModel $bitmapBodyModel)
{
for ($i = 0; $i < $bitmapBodyModel->bodySize; $i += 3) {
// Calculate line-ending and padding
if ($bitmapBodyModel->x >= $bitmapBodyModel->width) {
// If padding needed, ignore image-padding. Shift i to the ending of the current 32-bit-block
if ($bitmapBodyModel->usePadding) {
$i += $bitmapBodyModel->width % 4;
}
// Reset horizontal position
$bitmapBodyModel->x = 0;
// Raise the height-position (bottom-up)
$bitmapBodyModel->y++;
// Reached the image-height? Break the for-loop
if ($bitmapBodyModel->y > $bitmapBodyModel->height) {
break;
}
}
// Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body
$iPos = $i * 2;
$r = hexdec($bitmapBodyModel->body[$iPos + 4] . $bitmapBodyModel->body[$iPos + 5]);
$g = hexdec($bitmapBodyModel->body[$iPos + 2] . $bitmapBodyModel->body[$iPos + 3]);
$b = hexdec($bitmapBodyModel->body[$iPos] . $bitmapBodyModel->body[$iPos + 1]);
// Calculate and draw the pixel
$color = imagecolorallocate($bitmapBodyModel->image, (int)$r, (int)$g, (int)$b);
imagesetpixel($bitmapBodyModel->image, $bitmapBodyModel->x, $bitmapBodyModel->height - $bitmapBodyModel->y, $color);
// Raise the horizontal position
$bitmapBodyModel->x++;
}
} | [
"private",
"static",
"function",
"loopThroughBodyAndCalculatePixels",
"(",
"BitmapBodyModel",
"$",
"bitmapBodyModel",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"bitmapBodyModel",
"->",
"bodySize",
";",
"$",
"i",
"+=",
"3",
")",
"{",
"// Calculate line-ending and padding",
"if",
"(",
"$",
"bitmapBodyModel",
"->",
"x",
">=",
"$",
"bitmapBodyModel",
"->",
"width",
")",
"{",
"// If padding needed, ignore image-padding. Shift i to the ending of the current 32-bit-block",
"if",
"(",
"$",
"bitmapBodyModel",
"->",
"usePadding",
")",
"{",
"$",
"i",
"+=",
"$",
"bitmapBodyModel",
"->",
"width",
"%",
"4",
";",
"}",
"// Reset horizontal position",
"$",
"bitmapBodyModel",
"->",
"x",
"=",
"0",
";",
"// Raise the height-position (bottom-up)",
"$",
"bitmapBodyModel",
"->",
"y",
"++",
";",
"// Reached the image-height? Break the for-loop",
"if",
"(",
"$",
"bitmapBodyModel",
"->",
"y",
">",
"$",
"bitmapBodyModel",
"->",
"height",
")",
"{",
"break",
";",
"}",
"}",
"// Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body",
"$",
"iPos",
"=",
"$",
"i",
"*",
"2",
";",
"$",
"r",
"=",
"hexdec",
"(",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"+",
"4",
"]",
".",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"+",
"5",
"]",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"+",
"2",
"]",
".",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"+",
"3",
"]",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"]",
".",
"$",
"bitmapBodyModel",
"->",
"body",
"[",
"$",
"iPos",
"+",
"1",
"]",
")",
";",
"// Calculate and draw the pixel",
"$",
"color",
"=",
"imagecolorallocate",
"(",
"$",
"bitmapBodyModel",
"->",
"image",
",",
"(",
"int",
")",
"$",
"r",
",",
"(",
"int",
")",
"$",
"g",
",",
"(",
"int",
")",
"$",
"b",
")",
";",
"imagesetpixel",
"(",
"$",
"bitmapBodyModel",
"->",
"image",
",",
"$",
"bitmapBodyModel",
"->",
"x",
",",
"$",
"bitmapBodyModel",
"->",
"height",
"-",
"$",
"bitmapBodyModel",
"->",
"y",
",",
"$",
"color",
")",
";",
"// Raise the horizontal position",
"$",
"bitmapBodyModel",
"->",
"x",
"++",
";",
"}",
"}"
] | Loop through the data in the body of the bitmap
file and calculate each individual pixel based on the
bytes
Using a for-loop with index-calculation instead of str_split to avoid large memory consumption
Calculate the next DWORD-position in the body
@param BitmapBodyModel $bitmapBodyModel | [
"Loop",
"through",
"the",
"data",
"in",
"the",
"body",
"of",
"the",
"bitmap",
"file",
"and",
"calculate",
"each",
"individual",
"pixel",
"based",
"on",
"the",
"bytes"
] | 76e5d9ac8f9c50d06d39a995d13cc03742536548 | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/images/BitmapFactory.php#L84-L113 | train |
jenskooij/cloudcontrol | src/images/BitmapFactory.php | BitmapFactory.imageCreateFromBmp | public static function imageCreateFromBmp($pathToBitmapFile)
{
$bitmapFileData = self::getBitmapFileData($pathToBitmapFile);
$temp = unpack('H*', $bitmapFileData);
$hex = $temp[1];
$header = substr($hex, 0, 108);
list($width, $height) = self::calculateWidthAndHeight($header);
// Define starting X and Y
$x = 0;
$y = 1;
$image = imagecreatetruecolor($width, $height);
// Grab the body from the image
$body = substr($hex, 108);
// Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
$bodySize = (strlen($body) / 2);
$headerSize = ($width * $height);
// Use end-line padding? Only when needed
$usePadding = ($bodySize > ($headerSize * 3) + 4);
$bitmapBody = new BitmapBodyModel();
$bitmapBody->bodySize = $bodySize;
$bitmapBody->x = $x;
$bitmapBody->width = $width;
$bitmapBody->usePadding = $usePadding;
$bitmapBody->y = $y;
$bitmapBody->height = $height;
$bitmapBody->body = $body;
$bitmapBody->image = $image;
self::loopThroughBodyAndCalculatePixels($bitmapBody);
unset($body);
return $bitmapBody->image;
} | php | public static function imageCreateFromBmp($pathToBitmapFile)
{
$bitmapFileData = self::getBitmapFileData($pathToBitmapFile);
$temp = unpack('H*', $bitmapFileData);
$hex = $temp[1];
$header = substr($hex, 0, 108);
list($width, $height) = self::calculateWidthAndHeight($header);
// Define starting X and Y
$x = 0;
$y = 1;
$image = imagecreatetruecolor($width, $height);
// Grab the body from the image
$body = substr($hex, 108);
// Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
$bodySize = (strlen($body) / 2);
$headerSize = ($width * $height);
// Use end-line padding? Only when needed
$usePadding = ($bodySize > ($headerSize * 3) + 4);
$bitmapBody = new BitmapBodyModel();
$bitmapBody->bodySize = $bodySize;
$bitmapBody->x = $x;
$bitmapBody->width = $width;
$bitmapBody->usePadding = $usePadding;
$bitmapBody->y = $y;
$bitmapBody->height = $height;
$bitmapBody->body = $body;
$bitmapBody->image = $image;
self::loopThroughBodyAndCalculatePixels($bitmapBody);
unset($body);
return $bitmapBody->image;
} | [
"public",
"static",
"function",
"imageCreateFromBmp",
"(",
"$",
"pathToBitmapFile",
")",
"{",
"$",
"bitmapFileData",
"=",
"self",
"::",
"getBitmapFileData",
"(",
"$",
"pathToBitmapFile",
")",
";",
"$",
"temp",
"=",
"unpack",
"(",
"'H*'",
",",
"$",
"bitmapFileData",
")",
";",
"$",
"hex",
"=",
"$",
"temp",
"[",
"1",
"]",
";",
"$",
"header",
"=",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"108",
")",
";",
"list",
"(",
"$",
"width",
",",
"$",
"height",
")",
"=",
"self",
"::",
"calculateWidthAndHeight",
"(",
"$",
"header",
")",
";",
"// Define starting X and Y",
"$",
"x",
"=",
"0",
";",
"$",
"y",
"=",
"1",
";",
"$",
"image",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"// Grab the body from the image",
"$",
"body",
"=",
"substr",
"(",
"$",
"hex",
",",
"108",
")",
";",
"// Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars",
"$",
"bodySize",
"=",
"(",
"strlen",
"(",
"$",
"body",
")",
"/",
"2",
")",
";",
"$",
"headerSize",
"=",
"(",
"$",
"width",
"*",
"$",
"height",
")",
";",
"// Use end-line padding? Only when needed",
"$",
"usePadding",
"=",
"(",
"$",
"bodySize",
">",
"(",
"$",
"headerSize",
"*",
"3",
")",
"+",
"4",
")",
";",
"$",
"bitmapBody",
"=",
"new",
"BitmapBodyModel",
"(",
")",
";",
"$",
"bitmapBody",
"->",
"bodySize",
"=",
"$",
"bodySize",
";",
"$",
"bitmapBody",
"->",
"x",
"=",
"$",
"x",
";",
"$",
"bitmapBody",
"->",
"width",
"=",
"$",
"width",
";",
"$",
"bitmapBody",
"->",
"usePadding",
"=",
"$",
"usePadding",
";",
"$",
"bitmapBody",
"->",
"y",
"=",
"$",
"y",
";",
"$",
"bitmapBody",
"->",
"height",
"=",
"$",
"height",
";",
"$",
"bitmapBody",
"->",
"body",
"=",
"$",
"body",
";",
"$",
"bitmapBody",
"->",
"image",
"=",
"$",
"image",
";",
"self",
"::",
"loopThroughBodyAndCalculatePixels",
"(",
"$",
"bitmapBody",
")",
";",
"unset",
"(",
"$",
"body",
")",
";",
"return",
"$",
"bitmapBody",
"->",
"image",
";",
"}"
] | Create Image resource from Bitmap
@see http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
@author alexander at alexauto dot nl
@param string $pathToBitmapFile
@return resource
@throws \Exception | [
"Create",
"Image",
"resource",
"from",
"Bitmap"
] | 76e5d9ac8f9c50d06d39a995d13cc03742536548 | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/images/BitmapFactory.php#L126-L166 | train |
rawphp/RawConsole | src/RawPHP/RawConsole/Console.php | Console.run | public function run( $args )
{
$this->command = $this->getCommand( $args );
if ( NULL == $this->command )
{
throw new CommandException( 'Command: ' . $args[ 1 ] . ' not found' );
}
$this->processArgs( $this->command, $args );
return $this->command->execute();
} | php | public function run( $args )
{
$this->command = $this->getCommand( $args );
if ( NULL == $this->command )
{
throw new CommandException( 'Command: ' . $args[ 1 ] . ' not found' );
}
$this->processArgs( $this->command, $args );
return $this->command->execute();
} | [
"public",
"function",
"run",
"(",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"command",
"=",
"$",
"this",
"->",
"getCommand",
"(",
"$",
"args",
")",
";",
"if",
"(",
"NULL",
"==",
"$",
"this",
"->",
"command",
")",
"{",
"throw",
"new",
"CommandException",
"(",
"'Command: '",
".",
"$",
"args",
"[",
"1",
"]",
".",
"' not found'",
")",
";",
"}",
"$",
"this",
"->",
"processArgs",
"(",
"$",
"this",
"->",
"command",
",",
"$",
"args",
")",
";",
"return",
"$",
"this",
"->",
"command",
"->",
"execute",
"(",
")",
";",
"}"
] | Runs the requested command.
@param array $args command line arguments
@return int status code
@throws CommandException in exceptional circumstances | [
"Runs",
"the",
"requested",
"command",
"."
] | 602bedd10f24962305a7ac1979ed326852f4224a | https://github.com/rawphp/RawConsole/blob/602bedd10f24962305a7ac1979ed326852f4224a/src/RawPHP/RawConsole/Console.php#L90-L102 | train |
rawphp/RawConsole | src/RawPHP/RawConsole/Console.php | Console.getCommand | public function getCommand( $args )
{
$class = strtoupper( substr( $args[ 1 ], 0, 1 ) ) . substr( $args[ 1 ], 1 );
$class .= 'Command';
/** @var Command $command */
$command = NULL;
if ( class_exists( $class ) )
{
$command = new $class();
}
if ( NULL === $command && !empty( $this->namespaces ) )
{
foreach ( $this->namespaces as $ns )
{
$name = $ns . $class;
if ( class_exists( $name ) )
{
$command = new $name();
$command->init( $args );
break;
}
}
}
if ( NULL !== $command )
{
$command->configure();
}
return $command;
} | php | public function getCommand( $args )
{
$class = strtoupper( substr( $args[ 1 ], 0, 1 ) ) . substr( $args[ 1 ], 1 );
$class .= 'Command';
/** @var Command $command */
$command = NULL;
if ( class_exists( $class ) )
{
$command = new $class();
}
if ( NULL === $command && !empty( $this->namespaces ) )
{
foreach ( $this->namespaces as $ns )
{
$name = $ns . $class;
if ( class_exists( $name ) )
{
$command = new $name();
$command->init( $args );
break;
}
}
}
if ( NULL !== $command )
{
$command->configure();
}
return $command;
} | [
"public",
"function",
"getCommand",
"(",
"$",
"args",
")",
"{",
"$",
"class",
"=",
"strtoupper",
"(",
"substr",
"(",
"$",
"args",
"[",
"1",
"]",
",",
"0",
",",
"1",
")",
")",
".",
"substr",
"(",
"$",
"args",
"[",
"1",
"]",
",",
"1",
")",
";",
"$",
"class",
".=",
"'Command'",
";",
"/** @var Command $command */",
"$",
"command",
"=",
"NULL",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"command",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"if",
"(",
"NULL",
"===",
"$",
"command",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"namespaces",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
")",
"{",
"$",
"name",
"=",
"$",
"ns",
".",
"$",
"class",
";",
"if",
"(",
"class_exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"command",
"=",
"new",
"$",
"name",
"(",
")",
";",
"$",
"command",
"->",
"init",
"(",
"$",
"args",
")",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"NULL",
"!==",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"configure",
"(",
")",
";",
"}",
"return",
"$",
"command",
";",
"}"
] | Get the requested command.
@param array $args command line arguments
@global array $commandNamespaces command namespaces
@return ICommand the command | [
"Get",
"the",
"requested",
"command",
"."
] | 602bedd10f24962305a7ac1979ed326852f4224a | https://github.com/rawphp/RawConsole/blob/602bedd10f24962305a7ac1979ed326852f4224a/src/RawPHP/RawConsole/Console.php#L113-L148 | train |
rawphp/RawConsole | src/RawPHP/RawConsole/Console.php | Console.processArgs | public function processArgs( ICommand &$command, $args )
{
$i = 0;
$ops = array_slice( $args, 2 );
while ( $i < count( $ops ) )
{
$o = $ops[ $i ];
if ( Option::isShortCode( $o ) || Option::isLongCode( $o ) )
{
$option = Command::getOption( $command, $o );
if ( $option->isRequired )
{
$i++;
if ( !Util::validIndex( $i, $ops ) )
{
throw new CommandException( 'Missing argument for option: ' . $o );
}
Option::setRequiredValue( $option, $ops[ $i ] );
}
if ( $option->isOptional )
{
$value = NULL;
if ( $option->type === Type::BOOLEAN )
{
$value = TRUE;
}
else
{
$i++;
$value = $ops[ $i ];
}
if ( Util::validIndex( $i, $ops ) )
{
Option::setOptionalValue( $option, $value );
}
else if ( is_bool( $value ) )
{
Option::setOptionalValue( $option, $value );
}
}
}
$i++;
}
} | php | public function processArgs( ICommand &$command, $args )
{
$i = 0;
$ops = array_slice( $args, 2 );
while ( $i < count( $ops ) )
{
$o = $ops[ $i ];
if ( Option::isShortCode( $o ) || Option::isLongCode( $o ) )
{
$option = Command::getOption( $command, $o );
if ( $option->isRequired )
{
$i++;
if ( !Util::validIndex( $i, $ops ) )
{
throw new CommandException( 'Missing argument for option: ' . $o );
}
Option::setRequiredValue( $option, $ops[ $i ] );
}
if ( $option->isOptional )
{
$value = NULL;
if ( $option->type === Type::BOOLEAN )
{
$value = TRUE;
}
else
{
$i++;
$value = $ops[ $i ];
}
if ( Util::validIndex( $i, $ops ) )
{
Option::setOptionalValue( $option, $value );
}
else if ( is_bool( $value ) )
{
Option::setOptionalValue( $option, $value );
}
}
}
$i++;
}
} | [
"public",
"function",
"processArgs",
"(",
"ICommand",
"&",
"$",
"command",
",",
"$",
"args",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"ops",
"=",
"array_slice",
"(",
"$",
"args",
",",
"2",
")",
";",
"while",
"(",
"$",
"i",
"<",
"count",
"(",
"$",
"ops",
")",
")",
"{",
"$",
"o",
"=",
"$",
"ops",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"Option",
"::",
"isShortCode",
"(",
"$",
"o",
")",
"||",
"Option",
"::",
"isLongCode",
"(",
"$",
"o",
")",
")",
"{",
"$",
"option",
"=",
"Command",
"::",
"getOption",
"(",
"$",
"command",
",",
"$",
"o",
")",
";",
"if",
"(",
"$",
"option",
"->",
"isRequired",
")",
"{",
"$",
"i",
"++",
";",
"if",
"(",
"!",
"Util",
"::",
"validIndex",
"(",
"$",
"i",
",",
"$",
"ops",
")",
")",
"{",
"throw",
"new",
"CommandException",
"(",
"'Missing argument for option: '",
".",
"$",
"o",
")",
";",
"}",
"Option",
"::",
"setRequiredValue",
"(",
"$",
"option",
",",
"$",
"ops",
"[",
"$",
"i",
"]",
")",
";",
"}",
"if",
"(",
"$",
"option",
"->",
"isOptional",
")",
"{",
"$",
"value",
"=",
"NULL",
";",
"if",
"(",
"$",
"option",
"->",
"type",
"===",
"Type",
"::",
"BOOLEAN",
")",
"{",
"$",
"value",
"=",
"TRUE",
";",
"}",
"else",
"{",
"$",
"i",
"++",
";",
"$",
"value",
"=",
"$",
"ops",
"[",
"$",
"i",
"]",
";",
"}",
"if",
"(",
"Util",
"::",
"validIndex",
"(",
"$",
"i",
",",
"$",
"ops",
")",
")",
"{",
"Option",
"::",
"setOptionalValue",
"(",
"$",
"option",
",",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"Option",
"::",
"setOptionalValue",
"(",
"$",
"option",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"$",
"i",
"++",
";",
"}",
"}"
] | Processes the command line arguments and sets the option
values for the command.
@param ICommand $command the command reference
@param array $args command line args
@throws CommandException | [
"Processes",
"the",
"command",
"line",
"arguments",
"and",
"sets",
"the",
"option",
"values",
"for",
"the",
"command",
"."
] | 602bedd10f24962305a7ac1979ed326852f4224a | https://github.com/rawphp/RawConsole/blob/602bedd10f24962305a7ac1979ed326852f4224a/src/RawPHP/RawConsole/Console.php#L159-L213 | train |
dms-org/common.structure | src/Table/Form/Builder/TableCellValueFieldDefiner.php | TableCellValueFieldDefiner.withCellValuesAsField | public function withCellValuesAsField(IField $field) : TableFieldBuilder
{
return new TableFieldBuilder(
$this->fieldBuilder
->type(new TableType(
$this->cellClassName,
$this->columnField,
$this->rowField,
$field
))
);
} | php | public function withCellValuesAsField(IField $field) : TableFieldBuilder
{
return new TableFieldBuilder(
$this->fieldBuilder
->type(new TableType(
$this->cellClassName,
$this->columnField,
$this->rowField,
$field
))
);
} | [
"public",
"function",
"withCellValuesAsField",
"(",
"IField",
"$",
"field",
")",
":",
"TableFieldBuilder",
"{",
"return",
"new",
"TableFieldBuilder",
"(",
"$",
"this",
"->",
"fieldBuilder",
"->",
"type",
"(",
"new",
"TableType",
"(",
"$",
"this",
"->",
"cellClassName",
",",
"$",
"this",
"->",
"columnField",
",",
"$",
"this",
"->",
"rowField",
",",
"$",
"field",
")",
")",
")",
";",
"}"
] | Defines the cell values as the supplied field.
@param IField $field
@return TableFieldBuilder | [
"Defines",
"the",
"cell",
"values",
"as",
"the",
"supplied",
"field",
"."
] | 23f122182f60df5ec847047a81a39c8aab019ff1 | https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/Form/Builder/TableCellValueFieldDefiner.php#L69-L80 | train |
Retentio/Boomgo | src/Boomgo/Builder/Generator/AbstractGenerator.php | AbstractGenerator.setTwigGenerator | public function setTwigGenerator(TwigGenerator $twigGenerator)
{
$this->twigGenerator = $twigGenerator;
$this->twigGenerator->setTemplateDirs(array(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Templates'));
$this->twigGenerator->setMustOverwriteIfExists(true);
} | php | public function setTwigGenerator(TwigGenerator $twigGenerator)
{
$this->twigGenerator = $twigGenerator;
$this->twigGenerator->setTemplateDirs(array(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Templates'));
$this->twigGenerator->setMustOverwriteIfExists(true);
} | [
"public",
"function",
"setTwigGenerator",
"(",
"TwigGenerator",
"$",
"twigGenerator",
")",
"{",
"$",
"this",
"->",
"twigGenerator",
"=",
"$",
"twigGenerator",
";",
"$",
"this",
"->",
"twigGenerator",
"->",
"setTemplateDirs",
"(",
"array",
"(",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'Templates'",
")",
")",
";",
"$",
"this",
"->",
"twigGenerator",
"->",
"setMustOverwriteIfExists",
"(",
"true",
")",
";",
"}"
] | Define the twig generator instance
@param TwigGenerator $twigGenerator | [
"Define",
"the",
"twig",
"generator",
"instance"
] | 95cc53777425dd76cd0034046fa4f9e72c04d73a | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Builder/Generator/AbstractGenerator.php#L75-L80 | train |
Retentio/Boomgo | src/Boomgo/Builder/Generator/AbstractGenerator.php | AbstractGenerator.load | public function load($resources, $extension = '')
{
$finder = new Finder();
$collection = array();
if (is_array($resources)) {
foreach ($resources as $resource) {
$subcollection = array();
$subcollection = $this->load($resource);
$collection = array_merge($collection, $subcollection);
}
} elseif (is_dir($resources)) {
$files = $finder->files()->name('*'.$extension)->in($resources);
foreach ($files as $file) {
$collection[] = realpath($file->getPathName());
}
} elseif (is_file($resources)) {
$collection = array(realpath($resources));
} else {
throw new \InvalidArgumentException('Argument must be an absolute directory or a file path or both in an array');
}
return $collection;
} | php | public function load($resources, $extension = '')
{
$finder = new Finder();
$collection = array();
if (is_array($resources)) {
foreach ($resources as $resource) {
$subcollection = array();
$subcollection = $this->load($resource);
$collection = array_merge($collection, $subcollection);
}
} elseif (is_dir($resources)) {
$files = $finder->files()->name('*'.$extension)->in($resources);
foreach ($files as $file) {
$collection[] = realpath($file->getPathName());
}
} elseif (is_file($resources)) {
$collection = array(realpath($resources));
} else {
throw new \InvalidArgumentException('Argument must be an absolute directory or a file path or both in an array');
}
return $collection;
} | [
"public",
"function",
"load",
"(",
"$",
"resources",
",",
"$",
"extension",
"=",
"''",
")",
"{",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"collection",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"resources",
")",
")",
"{",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"resource",
")",
"{",
"$",
"subcollection",
"=",
"array",
"(",
")",
";",
"$",
"subcollection",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"resource",
")",
";",
"$",
"collection",
"=",
"array_merge",
"(",
"$",
"collection",
",",
"$",
"subcollection",
")",
";",
"}",
"}",
"elseif",
"(",
"is_dir",
"(",
"$",
"resources",
")",
")",
"{",
"$",
"files",
"=",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"name",
"(",
"'*'",
".",
"$",
"extension",
")",
"->",
"in",
"(",
"$",
"resources",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"collection",
"[",
"]",
"=",
"realpath",
"(",
"$",
"file",
"->",
"getPathName",
"(",
")",
")",
";",
"}",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"resources",
")",
")",
"{",
"$",
"collection",
"=",
"array",
"(",
"realpath",
"(",
"$",
"resources",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument must be an absolute directory or a file path or both in an array'",
")",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] | Return a collection of files
@param mixed $resources Absolute file or directory path or an array of both
@param string $extension File extension to load/filter with the prefixed dot (.php, .yml)
@throws InvalidArgumentException If resources aren't absolute dir or file path
@return array | [
"Return",
"a",
"collection",
"of",
"files"
] | 95cc53777425dd76cd0034046fa4f9e72c04d73a | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Builder/Generator/AbstractGenerator.php#L102-L125 | train |
praxigento/mobi_mod_pv | Service/Sale/Account/Pv.php | Pv.getSaleOrderData | private function getSaleOrderData($saleId)
{
/* get referral customer ID */
$entity = $this->daoGeneric->getEntityByPk(
Cfg::ENTITY_MAGE_SALES_ORDER,
[Cfg::E_COMMON_A_ENTITY_ID => $saleId],
[Cfg::E_SALE_ORDER_A_CUSTOMER_ID, Cfg::E_SALE_ORDER_A_INCREMENT_ID]
);
$custId = $entity[Cfg::E_SALE_ORDER_A_CUSTOMER_ID];
$incId = $entity[Cfg::E_SALE_ORDER_A_INCREMENT_ID];
return [$custId, $incId];
} | php | private function getSaleOrderData($saleId)
{
/* get referral customer ID */
$entity = $this->daoGeneric->getEntityByPk(
Cfg::ENTITY_MAGE_SALES_ORDER,
[Cfg::E_COMMON_A_ENTITY_ID => $saleId],
[Cfg::E_SALE_ORDER_A_CUSTOMER_ID, Cfg::E_SALE_ORDER_A_INCREMENT_ID]
);
$custId = $entity[Cfg::E_SALE_ORDER_A_CUSTOMER_ID];
$incId = $entity[Cfg::E_SALE_ORDER_A_INCREMENT_ID];
return [$custId, $incId];
} | [
"private",
"function",
"getSaleOrderData",
"(",
"$",
"saleId",
")",
"{",
"/* get referral customer ID */",
"$",
"entity",
"=",
"$",
"this",
"->",
"daoGeneric",
"->",
"getEntityByPk",
"(",
"Cfg",
"::",
"ENTITY_MAGE_SALES_ORDER",
",",
"[",
"Cfg",
"::",
"E_COMMON_A_ENTITY_ID",
"=>",
"$",
"saleId",
"]",
",",
"[",
"Cfg",
"::",
"E_SALE_ORDER_A_CUSTOMER_ID",
",",
"Cfg",
"::",
"E_SALE_ORDER_A_INCREMENT_ID",
"]",
")",
";",
"$",
"custId",
"=",
"$",
"entity",
"[",
"Cfg",
"::",
"E_SALE_ORDER_A_CUSTOMER_ID",
"]",
";",
"$",
"incId",
"=",
"$",
"entity",
"[",
"Cfg",
"::",
"E_SALE_ORDER_A_INCREMENT_ID",
"]",
";",
"return",
"[",
"$",
"custId",
",",
"$",
"incId",
"]",
";",
"}"
] | Get significant attributes of the sale order.
@param int $saleId
@return array [$custId, $incId] | [
"Get",
"significant",
"attributes",
"of",
"the",
"sale",
"order",
"."
] | d1540b7e94264527006e8b9fa68904a72a63928e | https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Service/Sale/Account/Pv.php#L124-L135 | train |
FlexModel/FlexModelBundle | Form/Type/FlexModelFormType.php | FlexModelFormType.getFieldType | private function getFieldType(array $formFieldConfiguration, array $fieldConfiguration)
{
if (isset($formFieldConfiguration['fieldtype'])) {
return $formFieldConfiguration['fieldtype'];
}
$fieldType = null;
switch ($fieldConfiguration['datatype']) {
case 'BOOLEAN':
$fieldType = CheckboxType::class;
break;
case 'DATE':
$fieldType = DateType::class;
break;
case 'DATEINTERVAL':
$fieldType = TextType::class;
break;
case 'DATETIME':
$fieldType = DateTimeType::class;
break;
case 'DECIMAL':
$fieldType = NumberType::class;
break;
case 'FILE':
$fieldType = FileType::class;
break;
case 'FLOAT':
$fieldType = NumberType::class;
break;
case 'INTEGER':
$fieldType = IntegerType::class;
break;
case 'SET':
$fieldType = ChoiceType::class;
break;
case 'TEXT':
case 'HTML':
case 'JSON':
$fieldType = TextareaType::class;
break;
case 'VARCHAR':
$fieldType = TextType::class;
break;
}
if (isset($formFieldConfiguration['options']) || isset($fieldConfiguration['options'])) {
$fieldType = ChoiceType::class;
}
return $fieldType;
} | php | private function getFieldType(array $formFieldConfiguration, array $fieldConfiguration)
{
if (isset($formFieldConfiguration['fieldtype'])) {
return $formFieldConfiguration['fieldtype'];
}
$fieldType = null;
switch ($fieldConfiguration['datatype']) {
case 'BOOLEAN':
$fieldType = CheckboxType::class;
break;
case 'DATE':
$fieldType = DateType::class;
break;
case 'DATEINTERVAL':
$fieldType = TextType::class;
break;
case 'DATETIME':
$fieldType = DateTimeType::class;
break;
case 'DECIMAL':
$fieldType = NumberType::class;
break;
case 'FILE':
$fieldType = FileType::class;
break;
case 'FLOAT':
$fieldType = NumberType::class;
break;
case 'INTEGER':
$fieldType = IntegerType::class;
break;
case 'SET':
$fieldType = ChoiceType::class;
break;
case 'TEXT':
case 'HTML':
case 'JSON':
$fieldType = TextareaType::class;
break;
case 'VARCHAR':
$fieldType = TextType::class;
break;
}
if (isset($formFieldConfiguration['options']) || isset($fieldConfiguration['options'])) {
$fieldType = ChoiceType::class;
}
return $fieldType;
} | [
"private",
"function",
"getFieldType",
"(",
"array",
"$",
"formFieldConfiguration",
",",
"array",
"$",
"fieldConfiguration",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'fieldtype'",
"]",
")",
")",
"{",
"return",
"$",
"formFieldConfiguration",
"[",
"'fieldtype'",
"]",
";",
"}",
"$",
"fieldType",
"=",
"null",
";",
"switch",
"(",
"$",
"fieldConfiguration",
"[",
"'datatype'",
"]",
")",
"{",
"case",
"'BOOLEAN'",
":",
"$",
"fieldType",
"=",
"CheckboxType",
"::",
"class",
";",
"break",
";",
"case",
"'DATE'",
":",
"$",
"fieldType",
"=",
"DateType",
"::",
"class",
";",
"break",
";",
"case",
"'DATEINTERVAL'",
":",
"$",
"fieldType",
"=",
"TextType",
"::",
"class",
";",
"break",
";",
"case",
"'DATETIME'",
":",
"$",
"fieldType",
"=",
"DateTimeType",
"::",
"class",
";",
"break",
";",
"case",
"'DECIMAL'",
":",
"$",
"fieldType",
"=",
"NumberType",
"::",
"class",
";",
"break",
";",
"case",
"'FILE'",
":",
"$",
"fieldType",
"=",
"FileType",
"::",
"class",
";",
"break",
";",
"case",
"'FLOAT'",
":",
"$",
"fieldType",
"=",
"NumberType",
"::",
"class",
";",
"break",
";",
"case",
"'INTEGER'",
":",
"$",
"fieldType",
"=",
"IntegerType",
"::",
"class",
";",
"break",
";",
"case",
"'SET'",
":",
"$",
"fieldType",
"=",
"ChoiceType",
"::",
"class",
";",
"break",
";",
"case",
"'TEXT'",
":",
"case",
"'HTML'",
":",
"case",
"'JSON'",
":",
"$",
"fieldType",
"=",
"TextareaType",
"::",
"class",
";",
"break",
";",
"case",
"'VARCHAR'",
":",
"$",
"fieldType",
"=",
"TextType",
"::",
"class",
";",
"break",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'options'",
"]",
")",
"||",
"isset",
"(",
"$",
"fieldConfiguration",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"fieldType",
"=",
"ChoiceType",
"::",
"class",
";",
"}",
"return",
"$",
"fieldType",
";",
"}"
] | Returns the field type for a field.
@param array $formFieldConfiguration
@param array $fieldConfiguration
@return array | [
"Returns",
"the",
"field",
"type",
"for",
"a",
"field",
"."
] | 7b4720d25b0dc6baf29b1da8ad7c67dfb2686460 | https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/Form/Type/FlexModelFormType.php#L99-L149 | train |
FlexModel/FlexModelBundle | Form/Type/FlexModelFormType.php | FlexModelFormType.getFieldOptions | protected function getFieldOptions(array $formFieldConfiguration, array $fieldConfiguration)
{
$options = array(
'label' => '',
'required' => false,
'constraints' => array(),
);
if (empty($fieldConfiguration)) {
$options['mapped'] = false;
}
if (isset($fieldConfiguration['label'])) {
$options['label'] = $fieldConfiguration['label'];
}
if (isset($fieldConfiguration['required'])) {
$options['required'] = $fieldConfiguration['required'];
}
if (isset($formFieldConfiguration['label'])) {
$options['label'] = $formFieldConfiguration['label'];
}
if (isset($formFieldConfiguration['widget'])) {
$options['widget'] = $formFieldConfiguration['widget'];
}
if (isset($formFieldConfiguration['format'])) {
$options['format'] = $formFieldConfiguration['format'];
}
$this->addFieldPlaceholder($options, $formFieldConfiguration, $fieldConfiguration);
$this->addFieldOptionsByDatatype($options, $fieldConfiguration);
$this->addFieldChoiceOptions($options, $formFieldConfiguration, $fieldConfiguration);
$this->addFieldConstraintOptions($options, $formFieldConfiguration);
return $options;
} | php | protected function getFieldOptions(array $formFieldConfiguration, array $fieldConfiguration)
{
$options = array(
'label' => '',
'required' => false,
'constraints' => array(),
);
if (empty($fieldConfiguration)) {
$options['mapped'] = false;
}
if (isset($fieldConfiguration['label'])) {
$options['label'] = $fieldConfiguration['label'];
}
if (isset($fieldConfiguration['required'])) {
$options['required'] = $fieldConfiguration['required'];
}
if (isset($formFieldConfiguration['label'])) {
$options['label'] = $formFieldConfiguration['label'];
}
if (isset($formFieldConfiguration['widget'])) {
$options['widget'] = $formFieldConfiguration['widget'];
}
if (isset($formFieldConfiguration['format'])) {
$options['format'] = $formFieldConfiguration['format'];
}
$this->addFieldPlaceholder($options, $formFieldConfiguration, $fieldConfiguration);
$this->addFieldOptionsByDatatype($options, $fieldConfiguration);
$this->addFieldChoiceOptions($options, $formFieldConfiguration, $fieldConfiguration);
$this->addFieldConstraintOptions($options, $formFieldConfiguration);
return $options;
} | [
"protected",
"function",
"getFieldOptions",
"(",
"array",
"$",
"formFieldConfiguration",
",",
"array",
"$",
"fieldConfiguration",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'label'",
"=>",
"''",
",",
"'required'",
"=>",
"false",
",",
"'constraints'",
"=>",
"array",
"(",
")",
",",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fieldConfiguration",
")",
")",
"{",
"$",
"options",
"[",
"'mapped'",
"]",
"=",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fieldConfiguration",
"[",
"'label'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'label'",
"]",
"=",
"$",
"fieldConfiguration",
"[",
"'label'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fieldConfiguration",
"[",
"'required'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'required'",
"]",
"=",
"$",
"fieldConfiguration",
"[",
"'required'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'label'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'label'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'label'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'widget'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'widget'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'widget'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'format'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'format'",
"]",
";",
"}",
"$",
"this",
"->",
"addFieldPlaceholder",
"(",
"$",
"options",
",",
"$",
"formFieldConfiguration",
",",
"$",
"fieldConfiguration",
")",
";",
"$",
"this",
"->",
"addFieldOptionsByDatatype",
"(",
"$",
"options",
",",
"$",
"fieldConfiguration",
")",
";",
"$",
"this",
"->",
"addFieldChoiceOptions",
"(",
"$",
"options",
",",
"$",
"formFieldConfiguration",
",",
"$",
"fieldConfiguration",
")",
";",
"$",
"this",
"->",
"addFieldConstraintOptions",
"(",
"$",
"options",
",",
"$",
"formFieldConfiguration",
")",
";",
"return",
"$",
"options",
";",
"}"
] | Returns the field options for a field.
@param array $formFieldConfiguration
@param array $fieldConfiguration
@return array | [
"Returns",
"the",
"field",
"options",
"for",
"a",
"field",
"."
] | 7b4720d25b0dc6baf29b1da8ad7c67dfb2686460 | https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/Form/Type/FlexModelFormType.php#L159-L191 | train |
FlexModel/FlexModelBundle | Form/Type/FlexModelFormType.php | FlexModelFormType.addFieldPlaceholder | public function addFieldPlaceholder(array &$options, array $formFieldConfiguration, array $fieldConfiguration)
{
$fieldType = $this->getFieldType($formFieldConfiguration, $fieldConfiguration);
if (isset($formFieldConfiguration['notices']['placeholder'])) {
if (in_array($fieldType, array(ChoiceType::class, DateType::class, BirthdayType::class, DateTimeType::class, CountryType::class))) {
$options['placeholder'] = $formFieldConfiguration['notices']['placeholder'];
} else {
$options['attr']['placeholder'] = $formFieldConfiguration['notices']['placeholder'];
}
}
} | php | public function addFieldPlaceholder(array &$options, array $formFieldConfiguration, array $fieldConfiguration)
{
$fieldType = $this->getFieldType($formFieldConfiguration, $fieldConfiguration);
if (isset($formFieldConfiguration['notices']['placeholder'])) {
if (in_array($fieldType, array(ChoiceType::class, DateType::class, BirthdayType::class, DateTimeType::class, CountryType::class))) {
$options['placeholder'] = $formFieldConfiguration['notices']['placeholder'];
} else {
$options['attr']['placeholder'] = $formFieldConfiguration['notices']['placeholder'];
}
}
} | [
"public",
"function",
"addFieldPlaceholder",
"(",
"array",
"&",
"$",
"options",
",",
"array",
"$",
"formFieldConfiguration",
",",
"array",
"$",
"fieldConfiguration",
")",
"{",
"$",
"fieldType",
"=",
"$",
"this",
"->",
"getFieldType",
"(",
"$",
"formFieldConfiguration",
",",
"$",
"fieldConfiguration",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'notices'",
"]",
"[",
"'placeholder'",
"]",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fieldType",
",",
"array",
"(",
"ChoiceType",
"::",
"class",
",",
"DateType",
"::",
"class",
",",
"BirthdayType",
"::",
"class",
",",
"DateTimeType",
"::",
"class",
",",
"CountryType",
"::",
"class",
")",
")",
")",
"{",
"$",
"options",
"[",
"'placeholder'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'notices'",
"]",
"[",
"'placeholder'",
"]",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'attr'",
"]",
"[",
"'placeholder'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'notices'",
"]",
"[",
"'placeholder'",
"]",
";",
"}",
"}",
"}"
] | Adds the placeholder for a field based on the type.
@param array $options
@param array $formFieldConfiguration
@param array $fieldConfiguration | [
"Adds",
"the",
"placeholder",
"for",
"a",
"field",
"based",
"on",
"the",
"type",
"."
] | 7b4720d25b0dc6baf29b1da8ad7c67dfb2686460 | https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/Form/Type/FlexModelFormType.php#L200-L211 | train |
FlexModel/FlexModelBundle | Form/Type/FlexModelFormType.php | FlexModelFormType.addFieldChoiceOptions | private function addFieldChoiceOptions(array &$options, array $formFieldConfiguration, array $fieldConfiguration)
{
if (isset($formFieldConfiguration['options'])) {
$fieldConfiguration['options'] = $formFieldConfiguration['options'];
}
if (isset($fieldConfiguration['options'])) {
$options['choices'] = array();
foreach ($fieldConfiguration['options'] as $option) {
$options['choices'][$option['label']] = $option['value'];
}
}
} | php | private function addFieldChoiceOptions(array &$options, array $formFieldConfiguration, array $fieldConfiguration)
{
if (isset($formFieldConfiguration['options'])) {
$fieldConfiguration['options'] = $formFieldConfiguration['options'];
}
if (isset($fieldConfiguration['options'])) {
$options['choices'] = array();
foreach ($fieldConfiguration['options'] as $option) {
$options['choices'][$option['label']] = $option['value'];
}
}
} | [
"private",
"function",
"addFieldChoiceOptions",
"(",
"array",
"&",
"$",
"options",
",",
"array",
"$",
"formFieldConfiguration",
",",
"array",
"$",
"fieldConfiguration",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"fieldConfiguration",
"[",
"'options'",
"]",
"=",
"$",
"formFieldConfiguration",
"[",
"'options'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fieldConfiguration",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'choices'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldConfiguration",
"[",
"'options'",
"]",
"as",
"$",
"option",
")",
"{",
"$",
"options",
"[",
"'choices'",
"]",
"[",
"$",
"option",
"[",
"'label'",
"]",
"]",
"=",
"$",
"option",
"[",
"'value'",
"]",
";",
"}",
"}",
"}"
] | Adds the choices option to the field options.
@param array $options
@param array $formFieldConfiguration
@param array $fieldConfiguration | [
"Adds",
"the",
"choices",
"option",
"to",
"the",
"field",
"options",
"."
] | 7b4720d25b0dc6baf29b1da8ad7c67dfb2686460 | https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/Form/Type/FlexModelFormType.php#L239-L251 | train |
FlexModel/FlexModelBundle | Form/Type/FlexModelFormType.php | FlexModelFormType.addFieldConstraintOptions | private function addFieldConstraintOptions(array &$options, array $formFieldConfiguration)
{
if ($options['required'] === true) {
$options['constraints'][] = new NotBlank();
}
if (isset($formFieldConfiguration['validators'])) {
$options['constraints'] = array();
foreach ($formFieldConfiguration['validators'] as $validatorClass => $validatorOptions) {
$options['constraints'][] = new $validatorClass($validatorOptions);
}
}
} | php | private function addFieldConstraintOptions(array &$options, array $formFieldConfiguration)
{
if ($options['required'] === true) {
$options['constraints'][] = new NotBlank();
}
if (isset($formFieldConfiguration['validators'])) {
$options['constraints'] = array();
foreach ($formFieldConfiguration['validators'] as $validatorClass => $validatorOptions) {
$options['constraints'][] = new $validatorClass($validatorOptions);
}
}
} | [
"private",
"function",
"addFieldConstraintOptions",
"(",
"array",
"&",
"$",
"options",
",",
"array",
"$",
"formFieldConfiguration",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'required'",
"]",
"===",
"true",
")",
"{",
"$",
"options",
"[",
"'constraints'",
"]",
"[",
"]",
"=",
"new",
"NotBlank",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formFieldConfiguration",
"[",
"'validators'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'constraints'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"formFieldConfiguration",
"[",
"'validators'",
"]",
"as",
"$",
"validatorClass",
"=>",
"$",
"validatorOptions",
")",
"{",
"$",
"options",
"[",
"'constraints'",
"]",
"[",
"]",
"=",
"new",
"$",
"validatorClass",
"(",
"$",
"validatorOptions",
")",
";",
"}",
"}",
"}"
] | Adds the constraints option to the field options.
@param array $options
@param array $formFieldConfiguration | [
"Adds",
"the",
"constraints",
"option",
"to",
"the",
"field",
"options",
"."
] | 7b4720d25b0dc6baf29b1da8ad7c67dfb2686460 | https://github.com/FlexModel/FlexModelBundle/blob/7b4720d25b0dc6baf29b1da8ad7c67dfb2686460/Form/Type/FlexModelFormType.php#L259-L271 | train |
kabachello/phpTextTable | TextTable.php | TextTable.setRows | public function setRows(array $rows)
{
$this->rows = $rows;
$this->setKeys(array_keys($this->rows[0]));
return $this;
} | php | public function setRows(array $rows)
{
$this->rows = $rows;
$this->setKeys(array_keys($this->rows[0]));
return $this;
} | [
"public",
"function",
"setRows",
"(",
"array",
"$",
"rows",
")",
"{",
"$",
"this",
"->",
"rows",
"=",
"$",
"rows",
";",
"$",
"this",
"->",
"setKeys",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"rows",
"[",
"0",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the array to be printed
@param array $rows
@return \kabachello\phpTextTable\TextTable | [
"Sets",
"the",
"array",
"to",
"be",
"printed"
] | 19cf95002dba3e1c2d183522ba2515f788efece9 | https://github.com/kabachello/phpTextTable/blob/19cf95002dba3e1c2d183522ba2515f788efece9/TextTable.php#L151-L156 | train |
kabachello/phpTextTable | TextTable.php | TextTable.calculateDimensions | protected function calculateDimensions()
{
foreach ($this->getRows() as $x => $row) {
foreach ($row as $y => $value) {
$this->calculateDimensionsForCell($x, $y, $value);
}
}
return $this;
} | php | protected function calculateDimensions()
{
foreach ($this->getRows() as $x => $row) {
foreach ($row as $y => $value) {
$this->calculateDimensionsForCell($x, $y, $value);
}
}
return $this;
} | [
"protected",
"function",
"calculateDimensions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRows",
"(",
")",
"as",
"$",
"x",
"=>",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"y",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"calculateDimensionsForCell",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Calculates the dimensions of the table
@return TextTable | [
"Calculates",
"the",
"dimensions",
"of",
"the",
"table"
] | 19cf95002dba3e1c2d183522ba2515f788efece9 | https://github.com/kabachello/phpTextTable/blob/19cf95002dba3e1c2d183522ba2515f788efece9/TextTable.php#L163-L171 | train |
kabachello/phpTextTable | TextTable.php | TextTable.print | public function print($row_key)
{
$this->calculateDimensions();
$result = '';
if ($this->getPrintHeader()) {
$result .= $this->printHeader();
} else {
$result .= $this->printRowLine();
}
if (! is_null($row_key)) {
$result .= $this->printRow($row_key, $this->getRows()[$row_key]);
} else {
foreach ($this->getRows() as $key => $data) {
$result .= $this->printRow($key, $data);
}
}
$result .= $this->printRowLine(false);
return $result;
} | php | public function print($row_key)
{
$this->calculateDimensions();
$result = '';
if ($this->getPrintHeader()) {
$result .= $this->printHeader();
} else {
$result .= $this->printRowLine();
}
if (! is_null($row_key)) {
$result .= $this->printRow($row_key, $this->getRows()[$row_key]);
} else {
foreach ($this->getRows() as $key => $data) {
$result .= $this->printRow($key, $data);
}
}
$result .= $this->printRowLine(false);
return $result;
} | [
"public",
"function",
"print",
"(",
"$",
"row_key",
")",
"{",
"$",
"this",
"->",
"calculateDimensions",
"(",
")",
";",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getPrintHeader",
"(",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"printHeader",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"printRowLine",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"row_key",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"printRow",
"(",
"$",
"row_key",
",",
"$",
"this",
"->",
"getRows",
"(",
")",
"[",
"$",
"row_key",
"]",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRows",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"printRow",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"}",
"}",
"$",
"result",
".=",
"$",
"this",
"->",
"printRowLine",
"(",
"false",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Prints the data to a text table
@return string | [
"Prints",
"the",
"data",
"to",
"a",
"text",
"table"
] | 19cf95002dba3e1c2d183522ba2515f788efece9 | https://github.com/kabachello/phpTextTable/blob/19cf95002dba3e1c2d183522ba2515f788efece9/TextTable.php#L198-L220 | train |
amarkal/amarkal-core | Utility.php | Utility.path_to_url | static function path_to_url( $path )
{
// We are replacing DIRECTORY_SEPARATOR with forward slash here
// to avoid issues in Windows systems
$path = str_replace( DIRECTORY_SEPARATOR, '/', $path);
$abspath = str_replace( DIRECTORY_SEPARATOR, '/', ABSPATH);
$url = str_replace( $abspath, '', $path );
return esc_url_raw( site_url( $url ) );
} | php | static function path_to_url( $path )
{
// We are replacing DIRECTORY_SEPARATOR with forward slash here
// to avoid issues in Windows systems
$path = str_replace( DIRECTORY_SEPARATOR, '/', $path);
$abspath = str_replace( DIRECTORY_SEPARATOR, '/', ABSPATH);
$url = str_replace( $abspath, '', $path );
return esc_url_raw( site_url( $url ) );
} | [
"static",
"function",
"path_to_url",
"(",
"$",
"path",
")",
"{",
"// We are replacing DIRECTORY_SEPARATOR with forward slash here ",
"// to avoid issues in Windows systems",
"$",
"path",
"=",
"str_replace",
"(",
"DIRECTORY_SEPARATOR",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"abspath",
"=",
"str_replace",
"(",
"DIRECTORY_SEPARATOR",
",",
"'/'",
",",
"ABSPATH",
")",
";",
"$",
"url",
"=",
"str_replace",
"(",
"$",
"abspath",
",",
"''",
",",
"$",
"path",
")",
";",
"return",
"esc_url_raw",
"(",
"site_url",
"(",
"$",
"url",
")",
")",
";",
"}"
] | Convert the given path to a URL.
@param string $path
@return string | [
"Convert",
"the",
"given",
"path",
"to",
"a",
"URL",
"."
] | 92062bc95fd9fef20a43a0bc3d35f50a4ac558d3 | https://github.com/amarkal/amarkal-core/blob/92062bc95fd9fef20a43a0bc3d35f50a4ac558d3/Utility.php#L16-L25 | train |
nicmart/DomainSpecificQuery | src/Lucene/Compiler/LuceneQueryCompiler.php | LuceneQueryCompiler.queryToAndExpression | private function queryToAndExpression(LuceneQuery $query)
{
$span = new SpanExpression('AND');
if (!$query->hasTrivialMainQuery())
$span->addExpression($query->getMainQuery());
$span->addExpressions($query->getFilterQueries());
return $span;
} | php | private function queryToAndExpression(LuceneQuery $query)
{
$span = new SpanExpression('AND');
if (!$query->hasTrivialMainQuery())
$span->addExpression($query->getMainQuery());
$span->addExpressions($query->getFilterQueries());
return $span;
} | [
"private",
"function",
"queryToAndExpression",
"(",
"LuceneQuery",
"$",
"query",
")",
"{",
"$",
"span",
"=",
"new",
"SpanExpression",
"(",
"'AND'",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"hasTrivialMainQuery",
"(",
")",
")",
"$",
"span",
"->",
"addExpression",
"(",
"$",
"query",
"->",
"getMainQuery",
"(",
")",
")",
";",
"$",
"span",
"->",
"addExpressions",
"(",
"$",
"query",
"->",
"getFilterQueries",
"(",
")",
")",
";",
"return",
"$",
"span",
";",
"}"
] | Convert a query to an AND expression
@param LuceneQuery $query
@return SpanExpression | [
"Convert",
"a",
"query",
"to",
"an",
"AND",
"expression"
] | 7c01fe94337afdfae5884809e8b5487127a63ac3 | https://github.com/nicmart/DomainSpecificQuery/blob/7c01fe94337afdfae5884809e8b5487127a63ac3/src/Lucene/Compiler/LuceneQueryCompiler.php#L132-L142 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.