repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
treffynnon/Navigator | lib/Treffynnon/Navigator/Coordinate/DmsParser.php | DmsParser.get | public function get($coord) {
$coord = rad2deg($coord);
$degrees = (integer) $coord;
$compass = '';
if ($this->direction == N::LAT) {
if ($degrees < 0)
$compass = 'S';
elseif ($degrees > 0)
$compass = 'N';
}elseif ($this->direction == N::LONG) {
if ($degrees < 0)
$compass = 'W';
elseif ($degrees > 0)
$compass = 'E';
}
$minutes = $coord - $degrees;
if ($minutes < 0)
$minutes -= (2 * $minutes);
if ($degrees < 0)
$degrees -= (2 * $degrees);
$minutes = $minutes * 60;
$seconds = $minutes - (integer) $minutes;
$minutes = (integer) $minutes;
$seconds = (float) $seconds * 60;
$coordinate = sprintf($this->output_format, $degrees, $minutes, $seconds, $compass);
return $coordinate;
} | php | public function get($coord) {
$coord = rad2deg($coord);
$degrees = (integer) $coord;
$compass = '';
if ($this->direction == N::LAT) {
if ($degrees < 0)
$compass = 'S';
elseif ($degrees > 0)
$compass = 'N';
}elseif ($this->direction == N::LONG) {
if ($degrees < 0)
$compass = 'W';
elseif ($degrees > 0)
$compass = 'E';
}
$minutes = $coord - $degrees;
if ($minutes < 0)
$minutes -= (2 * $minutes);
if ($degrees < 0)
$degrees -= (2 * $degrees);
$minutes = $minutes * 60;
$seconds = $minutes - (integer) $minutes;
$minutes = (integer) $minutes;
$seconds = (float) $seconds * 60;
$coordinate = sprintf($this->output_format, $degrees, $minutes, $seconds, $compass);
return $coordinate;
} | [
"public",
"function",
"get",
"(",
"$",
"coord",
")",
"{",
"$",
"coord",
"=",
"rad2deg",
"(",
"$",
"coord",
")",
";",
"$",
"degrees",
"=",
"(",
"integer",
")",
"$",
"coord",
";",
"$",
"compass",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"dir... | Get a string representation of the coordinate in DMS notation
@param float $coord
@return string | [
"Get",
"a",
"string",
"representation",
"of",
"the",
"coordinate",
"in",
"DMS",
"notation"
] | 329e01700e5e3f62361ed328437c524444c9c645 | https://github.com/treffynnon/Navigator/blob/329e01700e5e3f62361ed328437c524444c9c645/lib/Treffynnon/Navigator/Coordinate/DmsParser.php#L70-L98 | train |
apioo/fusio-adapter-sql | src/Action/SqlTable.php | SqlTable.convertRow | protected function convertRow(array $row, Connection $connection, Table $table)
{
$result = [];
foreach ($row as $key => $value) {
$type = $table->getColumn($key)->getType();
$val = $type->convertToPHPValue($value, $connection->getDatabasePlatform());
if ($type instanceof Types\DateTimeType) {
$val = $val->format(\DateTime::RFC3339);
} elseif ($type instanceof Types\DateTimeTzType) {
$val = $val->format(\DateTime::RFC3339_EXTENDED);
} elseif ($type instanceof Types\TimeType) {
$val = $val->format('H:i:s');
} elseif ($type instanceof Types\BinaryType || $type instanceof Types\BlobType) {
$val = base64_encode(stream_get_contents($val));
}
$result[$key] = $val;
}
return $result;
} | php | protected function convertRow(array $row, Connection $connection, Table $table)
{
$result = [];
foreach ($row as $key => $value) {
$type = $table->getColumn($key)->getType();
$val = $type->convertToPHPValue($value, $connection->getDatabasePlatform());
if ($type instanceof Types\DateTimeType) {
$val = $val->format(\DateTime::RFC3339);
} elseif ($type instanceof Types\DateTimeTzType) {
$val = $val->format(\DateTime::RFC3339_EXTENDED);
} elseif ($type instanceof Types\TimeType) {
$val = $val->format('H:i:s');
} elseif ($type instanceof Types\BinaryType || $type instanceof Types\BlobType) {
$val = base64_encode(stream_get_contents($val));
}
$result[$key] = $val;
}
return $result;
} | [
"protected",
"function",
"convertRow",
"(",
"array",
"$",
"row",
",",
"Connection",
"$",
"connection",
",",
"Table",
"$",
"table",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"... | Converts a raw database row to the correct PHP types
@param array $row
@param \Doctrine\DBAL\Connection $connection
@param \Doctrine\DBAL\Schema\Table $table
@return array
@throws \Doctrine\DBAL\Schema\SchemaException | [
"Converts",
"a",
"raw",
"database",
"row",
"to",
"the",
"correct",
"PHP",
"types"
] | 717b2d7dfbed2e076fe43626d20f8e25149a8e56 | https://github.com/apioo/fusio-adapter-sql/blob/717b2d7dfbed2e076fe43626d20f8e25149a8e56/src/Action/SqlTable.php#L341-L362 | train |
codemonkey1988/responsive-images | Classes/ViewHelpers/LoadRegisterViewHelper.php | LoadRegisterViewHelper.renderStatic | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
{
$key = $arguments['key'];
$value = $arguments['value'];
array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register);
$GLOBALS['TSFE']->register[$key] = $value;
$content = $renderChildrenClosure();
if ($content) {
// Restore register when content was rendered
$GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
return $content;
}
return '';
} | php | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
{
$key = $arguments['key'];
$value = $arguments['value'];
array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register);
$GLOBALS['TSFE']->register[$key] = $value;
$content = $renderChildrenClosure();
if ($content) {
// Restore register when content was rendered
$GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
return $content;
}
return '';
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"\\",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
":",
"string",
"{",
"$",
"key",
"=",
"$",
"arguments",
"[",
"'key'... | Renders the viewhelper.
@param array $arguments
@param \Closure $renderChildrenClosure
@param RenderingContextInterface $renderingContext
@return string | [
"Renders",
"the",
"viewhelper",
"."
] | 05aaba3a84164f8bbc66e20ed88e00d9eb1aa552 | https://github.com/codemonkey1988/responsive-images/blob/05aaba3a84164f8bbc66e20ed88e00d9eb1aa552/Classes/ViewHelpers/LoadRegisterViewHelper.php#L51-L69 | train |
treffynnon/Navigator | lib/Treffynnon/Navigator/Coordinate.php | Coordinate.guessParser | public function guessParser($coord) {
if (!is_numeric($coord) and !is_null($coord)) {
return new C\DmsParser;
}
return new C\DecimalParser;
} | php | public function guessParser($coord) {
if (!is_numeric($coord) and !is_null($coord)) {
return new C\DmsParser;
}
return new C\DecimalParser;
} | [
"public",
"function",
"guessParser",
"(",
"$",
"coord",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"coord",
")",
"and",
"!",
"is_null",
"(",
"$",
"coord",
")",
")",
"{",
"return",
"new",
"C",
"\\",
"DmsParser",
";",
"}",
"return",
"new",
"C"... | Guess the correct parser for a given coordinate
@param float|string $coord
@return \Treffynnon\Navigator\Coordinate\DecimalParser|\Treffynnon\Navigator\Coordinate\DmsParser | [
"Guess",
"the",
"correct",
"parser",
"for",
"a",
"given",
"coordinate"
] | 329e01700e5e3f62361ed328437c524444c9c645 | https://github.com/treffynnon/Navigator/blob/329e01700e5e3f62361ed328437c524444c9c645/lib/Treffynnon/Navigator/Coordinate.php#L55-L60 | train |
bummzack/translatable-dataobject | code/extensions/TranslatableUtility.php | TranslatableUtility.Master | public function Master()
{
if (Translatable::get_current_locale() != Translatable::default_locale()) {
if ($master = $this->owner->getTranslation(Translatable::default_locale())) {
return $master;
}
}
return $this->owner;
} | php | public function Master()
{
if (Translatable::get_current_locale() != Translatable::default_locale()) {
if ($master = $this->owner->getTranslation(Translatable::default_locale())) {
return $master;
}
}
return $this->owner;
} | [
"public",
"function",
"Master",
"(",
")",
"{",
"if",
"(",
"Translatable",
"::",
"get_current_locale",
"(",
")",
"!=",
"Translatable",
"::",
"default_locale",
"(",
")",
")",
"{",
"if",
"(",
"$",
"master",
"=",
"$",
"this",
"->",
"owner",
"->",
"getTransla... | Get the translation master of this page
@return SiteTree | [
"Get",
"the",
"translation",
"master",
"of",
"this",
"page"
] | a23cdefdb970d3d77c087350489107d3721ec709 | https://github.com/bummzack/translatable-dataobject/blob/a23cdefdb970d3d77c087350489107d3721ec709/code/extensions/TranslatableUtility.php#L9-L18 | train |
tacowordpress/tacowordpress | src/Term/Factory.php | Factory.create | public static function create($term, $taxonomy = null)
{
// Ex: Taco\Term\Factory::create('Keyword')
if (is_string($term) && class_exists($term)) {
return new $term;
}
if (!is_object($term)) {
$term = get_term($term, $taxonomy);
}
// TODO Refactor how this works to be more explicit and less guess
$class = str_replace(' ', '', ucwords(str_replace(Base::SEPARATOR, ' ', $term->taxonomy)));
if (!class_exists($class)) {
$class = str_replace(' ', '\\', ucwords(str_replace(Base::SEPARATOR, ' ', $term->taxonomy)));
}
$instance = new $class;
$instance->load($term->term_id);
return $instance;
} | php | public static function create($term, $taxonomy = null)
{
// Ex: Taco\Term\Factory::create('Keyword')
if (is_string($term) && class_exists($term)) {
return new $term;
}
if (!is_object($term)) {
$term = get_term($term, $taxonomy);
}
// TODO Refactor how this works to be more explicit and less guess
$class = str_replace(' ', '', ucwords(str_replace(Base::SEPARATOR, ' ', $term->taxonomy)));
if (!class_exists($class)) {
$class = str_replace(' ', '\\', ucwords(str_replace(Base::SEPARATOR, ' ', $term->taxonomy)));
}
$instance = new $class;
$instance->load($term->term_id);
return $instance;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"term",
",",
"$",
"taxonomy",
"=",
"null",
")",
"{",
"// Ex: Taco\\Term\\Factory::create('Keyword')",
"if",
"(",
"is_string",
"(",
"$",
"term",
")",
"&&",
"class_exists",
"(",
"$",
"term",
")",
")",
"{",
... | Create an instance based on a term object
This basically autoloads the meta data
@param mixed $term Object or term id
@param string $taxonomy
@return object | [
"Create",
"an",
"instance",
"based",
"on",
"a",
"term",
"object",
"This",
"basically",
"autoloads",
"the",
"meta",
"data"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Term/Factory.php#L28-L48 | train |
tacowordpress/tacowordpress | src/Term/Factory.php | Factory.createMultiple | public static function createMultiple($terms, $taxonomy = null)
{
if (!Arr::iterable($terms)) {
return $terms;
}
$out = array();
foreach ($terms as $term) {
$instance = self::create($term, $taxonomy);
$out[$instance->get('term_id')] = $instance;
}
return $out;
} | php | public static function createMultiple($terms, $taxonomy = null)
{
if (!Arr::iterable($terms)) {
return $terms;
}
$out = array();
foreach ($terms as $term) {
$instance = self::create($term, $taxonomy);
$out[$instance->get('term_id')] = $instance;
}
return $out;
} | [
"public",
"static",
"function",
"createMultiple",
"(",
"$",
"terms",
",",
"$",
"taxonomy",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"terms",
")",
")",
"{",
"return",
"$",
"terms",
";",
"}",
"$",
"out",
"=",
"array",... | Create multiple instances based on term objects
This basically autoloads the meta data
@param array $terms
@param string $taxonomy
@return array | [
"Create",
"multiple",
"instances",
"based",
"on",
"term",
"objects",
"This",
"basically",
"autoloads",
"the",
"meta",
"data"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Term/Factory.php#L58-L70 | train |
LibreHealthIO/lh-ehr-fhir-api | src/Http/Controllers/Auth/Traits/RegistersUsers.php | RegistersUsers.signupUpdate | public function signupUpdate(Request $request)
{
$this->middleware('auth:api');
$data = $request->all();
$validator = Validator::make($data, [
'firstname' => 'sometimes|required|max:255',
'surname' => 'sometimes|required|max:255',
'email' => 'sometimes|required|email|max:255|unique:users',
'mobile_number' => 'sometimes|min:10|unique:signup_data',
'password' => 'sometimes|required|min:6',
'gender' => 'sometimes|required',
'user_id' => 'required|integer',
]);
if (!empty($validator->errors()->messages())) {
return new Response([
'status' => 'FAIL',
'message' => 'Fail to update user signup data',
'Errors' => $validator->errors()
], 500);
} else {
try {
unset($data['_method']);
$signupModel = Signup::find($data['user_id']);
foreach ($data as $k => $ln) {
$signupModel->$k = $ln;
}
$signupModel->save();
return new Response([
'status' => 'OK',
'message' => 'User signup data updated',
], 201);
} catch (\Illuminate\Database\QueryException $ex) {
return new Response([
'status' => 'Fail',
'message' => 'Fail updating',
'Errors ' => $ex->getMessage()
]);
}
}
} | php | public function signupUpdate(Request $request)
{
$this->middleware('auth:api');
$data = $request->all();
$validator = Validator::make($data, [
'firstname' => 'sometimes|required|max:255',
'surname' => 'sometimes|required|max:255',
'email' => 'sometimes|required|email|max:255|unique:users',
'mobile_number' => 'sometimes|min:10|unique:signup_data',
'password' => 'sometimes|required|min:6',
'gender' => 'sometimes|required',
'user_id' => 'required|integer',
]);
if (!empty($validator->errors()->messages())) {
return new Response([
'status' => 'FAIL',
'message' => 'Fail to update user signup data',
'Errors' => $validator->errors()
], 500);
} else {
try {
unset($data['_method']);
$signupModel = Signup::find($data['user_id']);
foreach ($data as $k => $ln) {
$signupModel->$k = $ln;
}
$signupModel->save();
return new Response([
'status' => 'OK',
'message' => 'User signup data updated',
], 201);
} catch (\Illuminate\Database\QueryException $ex) {
return new Response([
'status' => 'Fail',
'message' => 'Fail updating',
'Errors ' => $ex->getMessage()
]);
}
}
} | [
"public",
"function",
"signupUpdate",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"middleware",
"(",
"'auth:api'",
")",
";",
"$",
"data",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"$",
"validator",
"=",
"Validator",
"::",
"make"... | Update user signup instance.
@param Request $request
@return Signup | [
"Update",
"user",
"signup",
"instance",
"."
] | 3250c17e537ed81030884ff6e7319a91483ccfc6 | https://github.com/LibreHealthIO/lh-ehr-fhir-api/blob/3250c17e537ed81030884ff6e7319a91483ccfc6/src/Http/Controllers/Auth/Traits/RegistersUsers.php#L111-L152 | train |
tianye/WechatMpSDK | src/Utils/JSON.php | JSON.encode | public static function encode($value, $options = 0, $depth = 512)
{
// multi-characters supported by default
$options |= JSON_UNESCAPED_UNICODE;
$data = version_compare(PHP_VERSION, '5.5.0', '>=')
? json_encode($value, $options, $depth)
: json_encode($value, $options);
if (JSON_ERROR_NONE !== json_last_error()) {
return $data;
}
return version_compare(PHP_VERSION, '5.4.0', '>=')
? $data
: preg_replace_callback("/\\\\u([0-9a-f]{2})([0-9a-f]{2})/iu", function ($pipe) {
return iconv(
strncasecmp(PHP_OS, 'WIN', 3) ? 'UCS-2BE' : 'UCS-2',
'UTF-8',
chr(hexdec($pipe[1])) . chr(hexdec($pipe[2]))
);
}, $data);
} | php | public static function encode($value, $options = 0, $depth = 512)
{
// multi-characters supported by default
$options |= JSON_UNESCAPED_UNICODE;
$data = version_compare(PHP_VERSION, '5.5.0', '>=')
? json_encode($value, $options, $depth)
: json_encode($value, $options);
if (JSON_ERROR_NONE !== json_last_error()) {
return $data;
}
return version_compare(PHP_VERSION, '5.4.0', '>=')
? $data
: preg_replace_callback("/\\\\u([0-9a-f]{2})([0-9a-f]{2})/iu", function ($pipe) {
return iconv(
strncasecmp(PHP_OS, 'WIN', 3) ? 'UCS-2BE' : 'UCS-2',
'UTF-8',
chr(hexdec($pipe[1])) . chr(hexdec($pipe[2]))
);
}, $data);
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"value",
",",
"$",
"options",
"=",
"0",
",",
"$",
"depth",
"=",
"512",
")",
"{",
"// multi-characters supported by default",
"$",
"options",
"|=",
"JSON_UNESCAPED_UNICODE",
";",
"$",
"data",
"=",
"version_com... | PHP >= 5.3 JSON_UNESCAPED_UNICODE constant supported
@param mixed $value The value (except a resource) being encoded.
@param int $options Bitmask consisting of blah...
@param int $depth Set the maximum depth. Must be greater than zero.
@see http://php.net/manual/en/function.json-encode.php
@return mixed Returns a string containing the JSON representation of data | [
"PHP",
">",
"=",
"5",
".",
"3",
"JSON_UNESCAPED_UNICODE",
"constant",
"supported"
] | 129ed5d08f1ead44fa773fcc864955794c69276b | https://github.com/tianye/WechatMpSDK/blob/129ed5d08f1ead44fa773fcc864955794c69276b/src/Utils/JSON.php#L36-L58 | train |
codemonkey1988/responsive-images | Classes/Utility/ConfigurationUtility.php | ConfigurationUtility.getExtensionConfig | public static function getExtensionConfig(): array
{
$supportedMimeTypes = self::DEFAULT_SUPPORTED_MIME_TYPES;
$desktopWidth = self::DEFAULT_DESKTOP_WIDTH;
$tabletWidth = self::DEFAULT_TABLET_WIDTH;
$smartphoneWidth = self::DEFAULT_SMARTPHONE_WIDTH;
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images'])) {
$supportedMimeTypes = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['supportedMimeTypes'] ?? self::DEFAULT_SUPPORTED_MIME_TYPES;
$desktopWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxDesktopImageWidth'] ?? self::DEFAULT_DESKTOP_WIDTH;
$tabletWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxTabletImageWidth'] ?? self::DEFAULT_TABLET_WIDTH;
$smartphoneWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxSmartphoneImageWidth'] ?? self::DEFAULT_SMARTPHONE_WIDTH;
} elseif (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['responsive_images'])) {
try {
$extConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['responsive_images']);
if (!empty($extConfig['supportedMimeTypes'])) {
$supportedMimeTypes = $extConfig['supportedMimeTypes'];
}
if (isset($extConfig['maxDesktopImageWidth']) && is_numeric($extConfig['maxDesktopImageWidth'])) {
$desktopWidth = (int)$extConfig['maxDesktopImageWidth'];
}
if (isset($extConfig['maxTabletImageWidth']) && is_numeric($extConfig['maxTabletImageWidth'])) {
$tabletWidth = (int)$extConfig['maxTabletImageWidth'];
}
if (isset($extConfig['maxSmartphoneImageWidth']) && is_numeric($extConfig['maxSmartphoneImageWidth'])) {
$smartphoneWidth = (int)$extConfig['maxSmartphoneImageWidth'];
}
} catch (\Exception $e) {
}
}
return [
'supportedMimeTypes' => $supportedMimeTypes,
'maxDesktopImageWidth' => $desktopWidth,
'maxTabletImageWidth' => $tabletWidth,
'maxSmartphoneImageWidth' => $smartphoneWidth,
];
} | php | public static function getExtensionConfig(): array
{
$supportedMimeTypes = self::DEFAULT_SUPPORTED_MIME_TYPES;
$desktopWidth = self::DEFAULT_DESKTOP_WIDTH;
$tabletWidth = self::DEFAULT_TABLET_WIDTH;
$smartphoneWidth = self::DEFAULT_SMARTPHONE_WIDTH;
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images'])) {
$supportedMimeTypes = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['supportedMimeTypes'] ?? self::DEFAULT_SUPPORTED_MIME_TYPES;
$desktopWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxDesktopImageWidth'] ?? self::DEFAULT_DESKTOP_WIDTH;
$tabletWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxTabletImageWidth'] ?? self::DEFAULT_TABLET_WIDTH;
$smartphoneWidth = (int)$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['responsive_images']['maxSmartphoneImageWidth'] ?? self::DEFAULT_SMARTPHONE_WIDTH;
} elseif (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['responsive_images'])) {
try {
$extConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['responsive_images']);
if (!empty($extConfig['supportedMimeTypes'])) {
$supportedMimeTypes = $extConfig['supportedMimeTypes'];
}
if (isset($extConfig['maxDesktopImageWidth']) && is_numeric($extConfig['maxDesktopImageWidth'])) {
$desktopWidth = (int)$extConfig['maxDesktopImageWidth'];
}
if (isset($extConfig['maxTabletImageWidth']) && is_numeric($extConfig['maxTabletImageWidth'])) {
$tabletWidth = (int)$extConfig['maxTabletImageWidth'];
}
if (isset($extConfig['maxSmartphoneImageWidth']) && is_numeric($extConfig['maxSmartphoneImageWidth'])) {
$smartphoneWidth = (int)$extConfig['maxSmartphoneImageWidth'];
}
} catch (\Exception $e) {
}
}
return [
'supportedMimeTypes' => $supportedMimeTypes,
'maxDesktopImageWidth' => $desktopWidth,
'maxTabletImageWidth' => $tabletWidth,
'maxSmartphoneImageWidth' => $smartphoneWidth,
];
} | [
"public",
"static",
"function",
"getExtensionConfig",
"(",
")",
":",
"array",
"{",
"$",
"supportedMimeTypes",
"=",
"self",
"::",
"DEFAULT_SUPPORTED_MIME_TYPES",
";",
"$",
"desktopWidth",
"=",
"self",
"::",
"DEFAULT_DESKTOP_WIDTH",
";",
"$",
"tabletWidth",
"=",
"se... | Returns extension management configuration as array.
@return array | [
"Returns",
"extension",
"management",
"configuration",
"as",
"array",
"."
] | 05aaba3a84164f8bbc66e20ed88e00d9eb1aa552 | https://github.com/codemonkey1988/responsive-images/blob/05aaba3a84164f8bbc66e20ed88e00d9eb1aa552/Classes/Utility/ConfigurationUtility.php#L32-L73 | train |
tacowordpress/tacowordpress | src/Term/Loader.php | Loader.load | public static function load($class)
{
$instance = new $class;
$taxonomy_key = $instance->getTaxonomyKey();
if (is_admin()) {
add_action(sprintf('created_%s', $taxonomy_key), array($instance, 'addSaveHooks'));
add_action(sprintf('edited_%s', $taxonomy_key), array($instance, 'addSaveHooks'));
add_action(sprintf('%s_add_form_fields', $taxonomy_key), array($instance, 'addMetaBoxes'));
add_action(sprintf('%s_edit_form_fields', $taxonomy_key), array($instance, 'addMetaBoxes'));
add_action(sprintf('manage_edit-%s_columns', $taxonomy_key), array($instance, 'addAdminColumns'), 10, 3);
add_action(sprintf('manage_%s_custom_column', $taxonomy_key), array($instance, 'renderAdminColumn'), 10, 3);
// TODO add sorting
//add_filter(sprintf('manage_edit-%s_sortable_columns', $taxonomy_key), array($instance, 'makeAdminColumnsSortable'));
//add_filter('request', array($instance, 'sortAdminColumns'));
}
} | php | public static function load($class)
{
$instance = new $class;
$taxonomy_key = $instance->getTaxonomyKey();
if (is_admin()) {
add_action(sprintf('created_%s', $taxonomy_key), array($instance, 'addSaveHooks'));
add_action(sprintf('edited_%s', $taxonomy_key), array($instance, 'addSaveHooks'));
add_action(sprintf('%s_add_form_fields', $taxonomy_key), array($instance, 'addMetaBoxes'));
add_action(sprintf('%s_edit_form_fields', $taxonomy_key), array($instance, 'addMetaBoxes'));
add_action(sprintf('manage_edit-%s_columns', $taxonomy_key), array($instance, 'addAdminColumns'), 10, 3);
add_action(sprintf('manage_%s_custom_column', $taxonomy_key), array($instance, 'renderAdminColumn'), 10, 3);
// TODO add sorting
//add_filter(sprintf('manage_edit-%s_sortable_columns', $taxonomy_key), array($instance, 'makeAdminColumnsSortable'));
//add_filter('request', array($instance, 'sortAdminColumns'));
}
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"$",
"instance",
"=",
"new",
"$",
"class",
";",
"$",
"taxonomy_key",
"=",
"$",
"instance",
"->",
"getTaxonomyKey",
"(",
")",
";",
"if",
"(",
"is_admin",
"(",
")",
")",
"{",
"add_act... | Load a term
@param string $class | [
"Load",
"a",
"term"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Term/Loader.php#L36-L54 | train |
dercoder/omnipay-webmoney | src/Message/CompletePurchaseResponse.php | CompletePurchaseResponse.calculateHash | private function calculateHash()
{
$hashType = $this->getHashType();
if ($hashType == 'sign') {
throw new InvalidResponseException('Control sign forming method "SIGN" is not supported');
} elseif ($hashType == null) {
throw new InvalidResponseException('Invalid signature type');
}
return strtoupper(hash(
$hashType,
$this->data['LMI_PAYEE_PURSE'].
$this->data['LMI_PAYMENT_AMOUNT'].
$this->data['LMI_PAYMENT_NO'].
$this->data['LMI_MODE'].
$this->data['LMI_SYS_INVS_NO'].
$this->data['LMI_SYS_TRANS_NO'].
$this->data['LMI_SYS_TRANS_DATE'].
$this->request->getSecretkey().
$this->data['LMI_PAYER_PURSE'].
$this->data['LMI_PAYER_WM']
));
} | php | private function calculateHash()
{
$hashType = $this->getHashType();
if ($hashType == 'sign') {
throw new InvalidResponseException('Control sign forming method "SIGN" is not supported');
} elseif ($hashType == null) {
throw new InvalidResponseException('Invalid signature type');
}
return strtoupper(hash(
$hashType,
$this->data['LMI_PAYEE_PURSE'].
$this->data['LMI_PAYMENT_AMOUNT'].
$this->data['LMI_PAYMENT_NO'].
$this->data['LMI_MODE'].
$this->data['LMI_SYS_INVS_NO'].
$this->data['LMI_SYS_TRANS_NO'].
$this->data['LMI_SYS_TRANS_DATE'].
$this->request->getSecretkey().
$this->data['LMI_PAYER_PURSE'].
$this->data['LMI_PAYER_WM']
));
} | [
"private",
"function",
"calculateHash",
"(",
")",
"{",
"$",
"hashType",
"=",
"$",
"this",
"->",
"getHashType",
"(",
")",
";",
"if",
"(",
"$",
"hashType",
"==",
"'sign'",
")",
"{",
"throw",
"new",
"InvalidResponseException",
"(",
"'Control sign forming method \... | Calculate hash to verify transaction details.
The control signature lets the merchant verify the source of data and the integrity of data transferred to the
Result URL in the 'Payment notification form '. The control signature is generating by 'sticking' together
values of parameters transmitted in the 'Payment notification form' in the following order: Merchant's purse
(LMI_PAYEE_PURSE); Amount (LMI_PAYMENT_AMOUNT); Purchase number (LMI_PAYMENT_NO); Test mode flag (LMI_MODE);
Account number in WebMoney Transfer (LMI_SYS_INVS_NO); Payment number in WebMoney Transfer (LMI_SYS_TRANS_NO);
Date and time of payment (LMI_SYS_TRANS_DATE); Secret Key (LMI_SECRET_KEY); Customer's purse (LMI_PAYER_PURSE);
Customer's WM id (LMI_PAYER_WM).
@return string
@throws InvalidResponseException | [
"Calculate",
"hash",
"to",
"verify",
"transaction",
"details",
"."
] | 7696c97d47e49901a23710320c7514f413749c23 | https://github.com/dercoder/omnipay-webmoney/blob/7696c97d47e49901a23710320c7514f413749c23/src/Message/CompletePurchaseResponse.php#L107-L130 | train |
tacowordpress/tacowordpress | src/Post.php | Post.load | public function load($id, $load_terms = true)
{
$info = (is_object($id)) ? $id : get_post($id);
if (!is_object($info)) {
return false;
}
// Handle how WordPress converts special chars out of the DB
// b/c even when you pass 'raw' as the 3rd partam to get_post,
// WordPress will still encode the values.
if (isset($info->post_title) && preg_match('/[&]{1,}/', $info->post_title)) {
$info->post_title = html_entity_decode($info->post_title);
}
$this->_info = (array) $info;
// meta
$meta = get_post_meta($this->_info[self::ID]);
if (Arr::iterable($meta)) {
foreach ($meta as $k => $v) {
$this->set($k, current($v));
}
}
// terms
if (!$load_terms) {
return true;
}
$this->loadTerms();
return true;
} | php | public function load($id, $load_terms = true)
{
$info = (is_object($id)) ? $id : get_post($id);
if (!is_object($info)) {
return false;
}
// Handle how WordPress converts special chars out of the DB
// b/c even when you pass 'raw' as the 3rd partam to get_post,
// WordPress will still encode the values.
if (isset($info->post_title) && preg_match('/[&]{1,}/', $info->post_title)) {
$info->post_title = html_entity_decode($info->post_title);
}
$this->_info = (array) $info;
// meta
$meta = get_post_meta($this->_info[self::ID]);
if (Arr::iterable($meta)) {
foreach ($meta as $k => $v) {
$this->set($k, current($v));
}
}
// terms
if (!$load_terms) {
return true;
}
$this->loadTerms();
return true;
} | [
"public",
"function",
"load",
"(",
"$",
"id",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"info",
"=",
"(",
"is_object",
"(",
"$",
"id",
")",
")",
"?",
"$",
"id",
":",
"get_post",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"is_object",
... | Load a post by ID
@param mixed $id String or integer as post ID, or post object
@param bool $load_terms
@return bool | [
"Load",
"a",
"post",
"by",
"ID"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L41-L72 | train |
tacowordpress/tacowordpress | src/Post.php | Post.loadTerms | public function loadTerms()
{
$taxonomy_keys = $this->getTaxonomyKeys();
if (!Arr::iterable($taxonomy_keys)) {
return false;
}
// TODO Move this to somewhere more efficient
// Check if this should be an instance of TacoTerm.
// If not, the object will just be a default WP object from wp_get_post_terms below.
$taxonomies_subclasses = array();
$subclasses = Term\Loader::getSubclasses();
foreach ($subclasses as $subclass) {
$term_instance = new $subclass;
$term_instance_taxonomy_key = $term_instance->getKey();
foreach ($taxonomy_keys as $taxonomy_key) {
if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
continue;
}
if ($term_instance_taxonomy_key !== $taxonomy_key) {
continue;
}
$taxonomies_subclasses[$taxonomy_key] = $subclass;
break;
}
}
foreach ($taxonomy_keys as $taxonomy_key) {
$terms = wp_get_post_terms($this->get(self::ID), $taxonomy_key);
if (!Arr::iterable($terms)) {
continue;
}
$terms = array_combine(
array_map('intval', Collection::pluck($terms, 'term_id')),
$terms
);
// Load Taco\Term if applicable
if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
$terms = Term\Factory::createMultiple($terms, $taxonomy_key);
}
$this->_terms[$taxonomy_key] = $terms;
}
return true;
} | php | public function loadTerms()
{
$taxonomy_keys = $this->getTaxonomyKeys();
if (!Arr::iterable($taxonomy_keys)) {
return false;
}
// TODO Move this to somewhere more efficient
// Check if this should be an instance of TacoTerm.
// If not, the object will just be a default WP object from wp_get_post_terms below.
$taxonomies_subclasses = array();
$subclasses = Term\Loader::getSubclasses();
foreach ($subclasses as $subclass) {
$term_instance = new $subclass;
$term_instance_taxonomy_key = $term_instance->getKey();
foreach ($taxonomy_keys as $taxonomy_key) {
if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
continue;
}
if ($term_instance_taxonomy_key !== $taxonomy_key) {
continue;
}
$taxonomies_subclasses[$taxonomy_key] = $subclass;
break;
}
}
foreach ($taxonomy_keys as $taxonomy_key) {
$terms = wp_get_post_terms($this->get(self::ID), $taxonomy_key);
if (!Arr::iterable($terms)) {
continue;
}
$terms = array_combine(
array_map('intval', Collection::pluck($terms, 'term_id')),
$terms
);
// Load Taco\Term if applicable
if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
$terms = Term\Factory::createMultiple($terms, $taxonomy_key);
}
$this->_terms[$taxonomy_key] = $terms;
}
return true;
} | [
"public",
"function",
"loadTerms",
"(",
")",
"{",
"$",
"taxonomy_keys",
"=",
"$",
"this",
"->",
"getTaxonomyKeys",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"taxonomy_keys",
")",
")",
"{",
"return",
"false",
";",
"}",
"// TODO M... | Load the terms
@return bool | [
"Load",
"the",
"terms"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L79-L127 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getDefaults | public function getDefaults()
{
global $user;
return array(
'post_type' => $this->getPostType(),
'post_author' => (is_object($user)) ? $user->ID : null,
'post_date' => current_time('mysql'),
'post_category' => array(0),
'post_status' => 'publish'
);
} | php | public function getDefaults()
{
global $user;
return array(
'post_type' => $this->getPostType(),
'post_author' => (is_object($user)) ? $user->ID : null,
'post_date' => current_time('mysql'),
'post_category' => array(0),
'post_status' => 'publish'
);
} | [
"public",
"function",
"getDefaults",
"(",
")",
"{",
"global",
"$",
"user",
";",
"return",
"array",
"(",
"'post_type'",
"=>",
"$",
"this",
"->",
"getPostType",
"(",
")",
",",
"'post_author'",
"=>",
"(",
"is_object",
"(",
"$",
"user",
")",
")",
"?",
"$",... | Get default values
Override this
@return array | [
"Get",
"default",
"values",
"Override",
"this"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L324-L334 | train |
tacowordpress/tacowordpress | src/Post.php | Post.registerPostType | public function registerPostType()
{
$config = $this->getPostTypeConfig();
if (empty($config)) {
return;
}
register_post_type($this->getPostType(), $config);
} | php | public function registerPostType()
{
$config = $this->getPostTypeConfig();
if (empty($config)) {
return;
}
register_post_type($this->getPostType(), $config);
} | [
"public",
"function",
"registerPostType",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getPostTypeConfig",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"return",
";",
"}",
"register_post_type",
"(",
"$",
"this",
"->",... | Register the post type
Override this if you need to | [
"Register",
"the",
"post",
"type",
"Override",
"this",
"if",
"you",
"need",
"to"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L488-L496 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getTaxonomy | public function getTaxonomy($key)
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return false;
}
$taxonomy = (array_key_exists($key, $taxonomies)) ? $taxonomies[$key] : false;
if (!$taxonomy) {
return false;
}
// Handle all of these:
// return array('one', 'two', 'three');
// return array('one'=>'One Category', 'two', 'three');
// return array(
// 'one'=>array('label'=>'One Category'),
// 'two'=>array('rewrite'=>array('slug'=>'foobar')),
// 'three'
// );
if (is_string($taxonomy)) {
$taxonomy = (is_numeric($key))
? array('label'=>self::getGeneratedTaxonomyLabel($taxonomy))
: array('label'=>$taxonomy);
} elseif (is_array($taxonomy) && !array_key_exists('label', $taxonomy)) {
$taxonomy['label'] = self::getGeneratedTaxonomyLabel($key);
}
// Unlike WordPress default, we'll default to hierarchical=true
// That's just more common for us
if (!array_key_exists('hierarchical', $taxonomy)) {
$taxonomy['hierarchical'] = true;
}
return $taxonomy;
} | php | public function getTaxonomy($key)
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return false;
}
$taxonomy = (array_key_exists($key, $taxonomies)) ? $taxonomies[$key] : false;
if (!$taxonomy) {
return false;
}
// Handle all of these:
// return array('one', 'two', 'three');
// return array('one'=>'One Category', 'two', 'three');
// return array(
// 'one'=>array('label'=>'One Category'),
// 'two'=>array('rewrite'=>array('slug'=>'foobar')),
// 'three'
// );
if (is_string($taxonomy)) {
$taxonomy = (is_numeric($key))
? array('label'=>self::getGeneratedTaxonomyLabel($taxonomy))
: array('label'=>$taxonomy);
} elseif (is_array($taxonomy) && !array_key_exists('label', $taxonomy)) {
$taxonomy['label'] = self::getGeneratedTaxonomyLabel($key);
}
// Unlike WordPress default, we'll default to hierarchical=true
// That's just more common for us
if (!array_key_exists('hierarchical', $taxonomy)) {
$taxonomy['hierarchical'] = true;
}
return $taxonomy;
} | [
"public",
"function",
"getTaxonomy",
"(",
"$",
"key",
")",
"{",
"$",
"taxonomies",
"=",
"$",
"this",
"->",
"getTaxonomies",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"taxonomies",
")",
")",
"{",
"return",
"false",
";",
"}",
... | Get a taxonomy by name
@param string $key
@return array | [
"Get",
"a",
"taxonomy",
"by",
"name"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L514-L549 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getTaxonomyKeys | public function getTaxonomyKeys()
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return array();
}
$out = array();
foreach ($taxonomies as $k => $taxonomy) {
$taxonomy = $this->getTaxonomy($k);
$out[] = $this->getTaxonomyKey($k, $taxonomy);
}
return $out;
} | php | public function getTaxonomyKeys()
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return array();
}
$out = array();
foreach ($taxonomies as $k => $taxonomy) {
$taxonomy = $this->getTaxonomy($k);
$out[] = $this->getTaxonomyKey($k, $taxonomy);
}
return $out;
} | [
"public",
"function",
"getTaxonomyKeys",
"(",
")",
"{",
"$",
"taxonomies",
"=",
"$",
"this",
"->",
"getTaxonomies",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"taxonomies",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
... | Get the taxonomy keys
@return array | [
"Get",
"the",
"taxonomy",
"keys"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L567-L580 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getTaxonomyKey | public function getTaxonomyKey($key, $taxonomy = array())
{
if (is_string($key)) {
return $key;
}
if (is_array($taxonomy) && array_key_exists('label', $taxonomy)) {
return Str::machine($taxonomy['label'], Base::SEPARATOR);
}
return $key;
} | php | public function getTaxonomyKey($key, $taxonomy = array())
{
if (is_string($key)) {
return $key;
}
if (is_array($taxonomy) && array_key_exists('label', $taxonomy)) {
return Str::machine($taxonomy['label'], Base::SEPARATOR);
}
return $key;
} | [
"public",
"function",
"getTaxonomyKey",
"(",
"$",
"key",
",",
"$",
"taxonomy",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"key",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"taxonomy",
... | Get a taxonomy key
@param string $key
@param array $taxonomy
@return string | [
"Get",
"a",
"taxonomy",
"key"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L589-L598 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getTaxonomiesInfo | public function getTaxonomiesInfo()
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return array();
}
$out = array();
foreach ($taxonomies as $k => $taxonomy) {
$taxonomy = $this->getTaxonomy($k);
$key = $this->getTaxonomyKey($k, $taxonomy);
$out[] = array(
'key' => $key,
'post_type' => $this->getPostType(),
'config' => $taxonomy
);
}
return $out;
} | php | public function getTaxonomiesInfo()
{
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return array();
}
$out = array();
foreach ($taxonomies as $k => $taxonomy) {
$taxonomy = $this->getTaxonomy($k);
$key = $this->getTaxonomyKey($k, $taxonomy);
$out[] = array(
'key' => $key,
'post_type' => $this->getPostType(),
'config' => $taxonomy
);
}
return $out;
} | [
"public",
"function",
"getTaxonomiesInfo",
"(",
")",
"{",
"$",
"taxonomies",
"=",
"$",
"this",
"->",
"getTaxonomies",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"taxonomies",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}"... | Get the taxonomy info
@return array | [
"Get",
"the",
"taxonomy",
"info"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L605-L623 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPostTypeConfig | public function getPostTypeConfig()
{
if (in_array($this->getPostType(), array('post', 'page'))) {
return null;
}
return array(
'labels' => array(
'name' => _x($this->getPlural(), 'post type general name'),
'singular_name' => _x($this->getSingular(), 'post type singular name'),
'add_new' => _x('Add New', $this->getSingular()),
'add_new_item' => __(sprintf('Add New %s', $this->getSingular())),
'edit_item' => __(sprintf('Edit %s', $this->getSingular())),
'new_item' => __(sprintf('New %s', $this->getPlural())),
'view_item' => __(sprintf('View %s', $this->getSingular())),
'search_items' => __(sprintf('Search %s', $this->getPlural())),
'not_found' => __(sprintf('No %s found', $this->getPlural())),
'not_found_in_trash'=> __(sprintf('No %s found in Trash', $this->getPlural())),
'parent_item_colon' => ''
),
'hierarchical' => $this->getHierarchical(),
'public' => $this->getPublic(),
'supports' => $this->getSupports(),
'show_in_menu' => $this->getShowInMenu(),
'show_in_admin_bar' => $this->getShowInAdminBar(),
'menu_icon' => $this->getMenuIcon(),
'menu_position' => $this->getMenuPosition(),
'exclude_from_search' => $this->getExcludeFromSearch(),
'has_archive' => $this->getHasArchive(),
'rewrite' => $this->getRewrite(),
'publicly_queryable' => $this->getPubliclyQueryable(),
);
} | php | public function getPostTypeConfig()
{
if (in_array($this->getPostType(), array('post', 'page'))) {
return null;
}
return array(
'labels' => array(
'name' => _x($this->getPlural(), 'post type general name'),
'singular_name' => _x($this->getSingular(), 'post type singular name'),
'add_new' => _x('Add New', $this->getSingular()),
'add_new_item' => __(sprintf('Add New %s', $this->getSingular())),
'edit_item' => __(sprintf('Edit %s', $this->getSingular())),
'new_item' => __(sprintf('New %s', $this->getPlural())),
'view_item' => __(sprintf('View %s', $this->getSingular())),
'search_items' => __(sprintf('Search %s', $this->getPlural())),
'not_found' => __(sprintf('No %s found', $this->getPlural())),
'not_found_in_trash'=> __(sprintf('No %s found in Trash', $this->getPlural())),
'parent_item_colon' => ''
),
'hierarchical' => $this->getHierarchical(),
'public' => $this->getPublic(),
'supports' => $this->getSupports(),
'show_in_menu' => $this->getShowInMenu(),
'show_in_admin_bar' => $this->getShowInAdminBar(),
'menu_icon' => $this->getMenuIcon(),
'menu_position' => $this->getMenuPosition(),
'exclude_from_search' => $this->getExcludeFromSearch(),
'has_archive' => $this->getHasArchive(),
'rewrite' => $this->getRewrite(),
'publicly_queryable' => $this->getPubliclyQueryable(),
);
} | [
"public",
"function",
"getPostTypeConfig",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"getPostType",
"(",
")",
",",
"array",
"(",
"'post'",
",",
"'page'",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"array",
"(",
"'la... | Get the post type config
@return array | [
"Get",
"the",
"post",
"type",
"config"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L639-L671 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getMenuIcon | public function getMenuIcon()
{
// Look for these files by default
// If your plugin directory contains an [post-type].png file, that will by default be the icon
// Ex: hot-sauce.png
$reflector = new \ReflectionClass(get_called_class());
$dir = basename(dirname($reflector->getFileName()));
$post_type = $this->getPostType();
$fnames = array(
$post_type.'.png',
$post_type.'.gif',
$post_type.'.jpg'
);
foreach ($fnames as $fname) {
$fpath = sprintf('%s/%s/%s', WP_PLUGIN_DIR, $dir, $fname);
if (!file_exists($fpath)) {
continue;
}
return sprintf('%s/%s/%s', WP_PLUGIN_URL, $dir, $fname);
}
return '';
} | php | public function getMenuIcon()
{
// Look for these files by default
// If your plugin directory contains an [post-type].png file, that will by default be the icon
// Ex: hot-sauce.png
$reflector = new \ReflectionClass(get_called_class());
$dir = basename(dirname($reflector->getFileName()));
$post_type = $this->getPostType();
$fnames = array(
$post_type.'.png',
$post_type.'.gif',
$post_type.'.jpg'
);
foreach ($fnames as $fname) {
$fpath = sprintf('%s/%s/%s', WP_PLUGIN_DIR, $dir, $fname);
if (!file_exists($fpath)) {
continue;
}
return sprintf('%s/%s/%s', WP_PLUGIN_URL, $dir, $fname);
}
return '';
} | [
"public",
"function",
"getMenuIcon",
"(",
")",
"{",
"// Look for these files by default",
"// If your plugin directory contains an [post-type].png file, that will by default be the icon",
"// Ex: hot-sauce.png",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_called_... | Get the menu icon
@return string | [
"Get",
"the",
"menu",
"icon"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L720-L742 | train |
tacowordpress/tacowordpress | src/Post.php | Post.sortAdminColumns | public function sortAdminColumns($vars)
{
if (!isset($vars['orderby'])) {
return $vars;
}
$admin_columns = $this->getAdminColumns();
if (!Arr::iterable($admin_columns)) {
return $vars;
}
foreach ($admin_columns as $k) {
if ($vars['orderby'] !== $k) {
continue;
}
$vars = array_merge($vars, array(
'meta_key'=> $k,
'orderby' => 'meta_value'
));
break;
}
return $vars;
} | php | public function sortAdminColumns($vars)
{
if (!isset($vars['orderby'])) {
return $vars;
}
$admin_columns = $this->getAdminColumns();
if (!Arr::iterable($admin_columns)) {
return $vars;
}
foreach ($admin_columns as $k) {
if ($vars['orderby'] !== $k) {
continue;
}
$vars = array_merge($vars, array(
'meta_key'=> $k,
'orderby' => 'meta_value'
));
break;
}
return $vars;
} | [
"public",
"function",
"sortAdminColumns",
"(",
"$",
"vars",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"vars",
"[",
"'orderby'",
"]",
")",
")",
"{",
"return",
"$",
"vars",
";",
"}",
"$",
"admin_columns",
"=",
"$",
"this",
"->",
"getAdminColumns",
"... | Sort the admin columns if necessary
@param array $vars
@return array | [
"Sort",
"the",
"admin",
"columns",
"if",
"necessary"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L780-L804 | train |
tacowordpress/tacowordpress | src/Post.php | Post.makeAdminTaxonomyColumnsSortable | public function makeAdminTaxonomyColumnsSortable($clauses, $wp_query)
{
global $wpdb;
// Not sorting at all? Get out.
if (!array_key_exists('orderby', $wp_query->query)) {
return $clauses;
}
if ($wp_query->query['orderby'] !== 'meta_value') {
return $clauses;
}
if (!array_key_exists('meta_key', $wp_query->query)) {
return $clauses;
}
// No taxonomies defined? Get out.
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return $clauses;
}
// Not sorting by a taxonomy? Get out.
$sortable_taxonomy_key = null;
foreach ($taxonomies as $taxonomy_key => $taxonomy) {
$taxonomy_key = (is_int($taxonomy_key)) ? $taxonomy : $taxonomy_key;
if ($wp_query->query['meta_key'] !== $taxonomy_key) {
continue;
}
$sortable_taxonomy_key = $taxonomy_key;
break;
}
if (!$sortable_taxonomy_key) {
return $clauses;
}
if ($wp_query->query['meta_key'] !== $sortable_taxonomy_key) {
return $clauses;
}
// Now we know which taxonomy the user is sorting by
// but WordPress will think we're sorting by a meta_key.
// Correct for this bad assumption by WordPress.
$clauses['where'] = str_replace(
array(
"AND ({$wpdb->postmeta}.meta_key = '".$taxonomy."' )",
"AND ( \n {$wpdb->postmeta}.meta_key = '".$taxonomy."'\n)"
),
'',
$clauses['where']
);
// This is how we find the posts
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id)
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
";
$clauses['where'] .= "AND (taxonomy = '".$taxonomy."' OR taxonomy IS NULL)";
$clauses['groupby'] = "object_id";
$clauses['orderby'] = "GROUP_CONCAT({$wpdb->terms}.name ORDER BY name ASC)";
$clauses['orderby'] .= (strtoupper($wp_query->get('order')) == 'ASC') ? 'ASC' : 'DESC';
return $clauses;
} | php | public function makeAdminTaxonomyColumnsSortable($clauses, $wp_query)
{
global $wpdb;
// Not sorting at all? Get out.
if (!array_key_exists('orderby', $wp_query->query)) {
return $clauses;
}
if ($wp_query->query['orderby'] !== 'meta_value') {
return $clauses;
}
if (!array_key_exists('meta_key', $wp_query->query)) {
return $clauses;
}
// No taxonomies defined? Get out.
$taxonomies = $this->getTaxonomies();
if (!Arr::iterable($taxonomies)) {
return $clauses;
}
// Not sorting by a taxonomy? Get out.
$sortable_taxonomy_key = null;
foreach ($taxonomies as $taxonomy_key => $taxonomy) {
$taxonomy_key = (is_int($taxonomy_key)) ? $taxonomy : $taxonomy_key;
if ($wp_query->query['meta_key'] !== $taxonomy_key) {
continue;
}
$sortable_taxonomy_key = $taxonomy_key;
break;
}
if (!$sortable_taxonomy_key) {
return $clauses;
}
if ($wp_query->query['meta_key'] !== $sortable_taxonomy_key) {
return $clauses;
}
// Now we know which taxonomy the user is sorting by
// but WordPress will think we're sorting by a meta_key.
// Correct for this bad assumption by WordPress.
$clauses['where'] = str_replace(
array(
"AND ({$wpdb->postmeta}.meta_key = '".$taxonomy."' )",
"AND ( \n {$wpdb->postmeta}.meta_key = '".$taxonomy."'\n)"
),
'',
$clauses['where']
);
// This is how we find the posts
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id)
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
";
$clauses['where'] .= "AND (taxonomy = '".$taxonomy."' OR taxonomy IS NULL)";
$clauses['groupby'] = "object_id";
$clauses['orderby'] = "GROUP_CONCAT({$wpdb->terms}.name ORDER BY name ASC)";
$clauses['orderby'] .= (strtoupper($wp_query->get('order')) == 'ASC') ? 'ASC' : 'DESC';
return $clauses;
} | [
"public",
"function",
"makeAdminTaxonomyColumnsSortable",
"(",
"$",
"clauses",
",",
"$",
"wp_query",
")",
"{",
"global",
"$",
"wpdb",
";",
"// Not sorting at all? Get out.",
"if",
"(",
"!",
"array_key_exists",
"(",
"'orderby'",
",",
"$",
"wp_query",
"->",
"query",... | Make the admin taxonomy columns sortable
Admittedly this is a bit hackish
@link http://wordpress.stackexchange.com/questions/109955/custom-table-column-sortable-by-taxonomy-query
@param array $clauses
@param object $wp_query
@return array | [
"Make",
"the",
"admin",
"taxonomy",
"columns",
"sortable",
"Admittedly",
"this",
"is",
"a",
"bit",
"hackish"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L815-L877 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getHideTitleFromAdminColumns | public function getHideTitleFromAdminColumns()
{
if (in_array('title', $this->getAdminColumns())) {
return false;
}
$supports = $this->getSupports();
if (is_array($supports) && in_array('title', $supports)) {
return false;
}
return true;
} | php | public function getHideTitleFromAdminColumns()
{
if (in_array('title', $this->getAdminColumns())) {
return false;
}
$supports = $this->getSupports();
if (is_array($supports) && in_array('title', $supports)) {
return false;
}
return true;
} | [
"public",
"function",
"getHideTitleFromAdminColumns",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"'title'",
",",
"$",
"this",
"->",
"getAdminColumns",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"supports",
"=",
"$",
"this",
"->",
"getSupp... | Hide the title from admin columns?
@return bool | [
"Hide",
"the",
"title",
"from",
"admin",
"columns?"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L897-L909 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPostType | public function getPostType()
{
$called_class_segments = explode('\\', get_called_class());
$class_name = end($called_class_segments);
return (is_null($this->post_type))
? Str::machine(Str::camelToHuman($class_name), Base::SEPARATOR)
: $this->post_type;
} | php | public function getPostType()
{
$called_class_segments = explode('\\', get_called_class());
$class_name = end($called_class_segments);
return (is_null($this->post_type))
? Str::machine(Str::camelToHuman($class_name), Base::SEPARATOR)
: $this->post_type;
} | [
"public",
"function",
"getPostType",
"(",
")",
"{",
"$",
"called_class_segments",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_called_class",
"(",
")",
")",
";",
"$",
"class_name",
"=",
"end",
"(",
"$",
"called_class_segments",
")",
";",
"return",
"(",
"is_null"... | Get the post type
@return string | [
"Get",
"the",
"post",
"type"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L950-L957 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPairs | public static function getPairs($args = array())
{
$called_class = get_called_class();
$instance = Post\Factory::create($called_class);
// Optimize the query if no args
// Unfortunately, WP doesn't provide a clean way to specify which columns to select
// If WP allowed that, this custom SQL wouldn't be necessary
if (!Arr::iterable($args)) {
global $wpdb;
$sql = sprintf(
"SELECT
p.ID,
p.post_title
FROM $wpdb->posts p
WHERE p.post_type = '%s'
AND (p.post_status = 'publish')
ORDER BY p.post_title ASC",
$instance->getPostType()
);
$results = $wpdb->get_results($sql);
if (!Arr::iterable($results)) {
return array();
}
return array_combine(
Collection::pluck($results, 'ID'),
Collection::pluck($results, 'post_title')
);
}
// Custom args provided
$default_args = array(
'post_type' => $instance->getPostType(),
'numberposts'=> -1,
'order' => 'ASC',
'orderby' => 'title',
);
$args = (Arr::iterable($args)) ? $args : $default_args;
if (!array_key_exists('post_type', $args)) {
$args['post_type'] = $instance->getPostType();
}
$all = get_posts($args);
if (!Arr::iterable($all)) {
return array();
}
return array_combine(
Collection::pluck($all, self::ID),
Collection::pluck($all, 'post_title')
);
} | php | public static function getPairs($args = array())
{
$called_class = get_called_class();
$instance = Post\Factory::create($called_class);
// Optimize the query if no args
// Unfortunately, WP doesn't provide a clean way to specify which columns to select
// If WP allowed that, this custom SQL wouldn't be necessary
if (!Arr::iterable($args)) {
global $wpdb;
$sql = sprintf(
"SELECT
p.ID,
p.post_title
FROM $wpdb->posts p
WHERE p.post_type = '%s'
AND (p.post_status = 'publish')
ORDER BY p.post_title ASC",
$instance->getPostType()
);
$results = $wpdb->get_results($sql);
if (!Arr::iterable($results)) {
return array();
}
return array_combine(
Collection::pluck($results, 'ID'),
Collection::pluck($results, 'post_title')
);
}
// Custom args provided
$default_args = array(
'post_type' => $instance->getPostType(),
'numberposts'=> -1,
'order' => 'ASC',
'orderby' => 'title',
);
$args = (Arr::iterable($args)) ? $args : $default_args;
if (!array_key_exists('post_type', $args)) {
$args['post_type'] = $instance->getPostType();
}
$all = get_posts($args);
if (!Arr::iterable($all)) {
return array();
}
return array_combine(
Collection::pluck($all, self::ID),
Collection::pluck($all, 'post_title')
);
} | [
"public",
"static",
"function",
"getPairs",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"called_class",
"=",
"get_called_class",
"(",
")",
";",
"$",
"instance",
"=",
"Post",
"\\",
"Factory",
"::",
"create",
"(",
"$",
"called_class",
")",
"... | Get the pairs
@param array $args for get_posts()
@return array | [
"Get",
"the",
"pairs"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L985-L1037 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getWhere | public static function getWhere($args = array(), $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
// Allow sorting both by core fields and custom fields
// See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
$default_orderby = $instance->getDefaultOrderBy();
$default_order = $instance->getDefaultOrder();
$default_args = array(
'post_type' => $instance->getPostType(),
'numberposts'=> -1,
'orderby' => $default_orderby,
'order' => $default_order,
);
// Sometimes you will specify a default orderby using getDefaultOrderBy
if ($default_orderby !== 'menu_order') {
$fields = $instance->getFields();
if (array_key_exists($default_orderby, $fields)) {
$default_args['meta_key'] = $default_orderby;
// Number fields should be sorted numerically, not alphabetically
// Of course, this currently requires you to use type=number to achieve numeric sorting
$default_args['orderby'] = ($fields[$default_orderby]['type'] === 'number')
? 'meta_value_num'
: 'meta_value';
}
}
// But other times, you'll just pass in orderby via $args,
// e.g. if you call getBy or getWhere with the $args param
if (array_key_exists('orderby', $args)) {
$fields = $instance->getFields();
if (array_key_exists($args['orderby'], $fields)) {
$args['meta_key'] = $args['orderby'];
// Number fields should be sorted numerically, not alphabetically
// Of course, this currently requires you to use type=number to achieve numeric sorting
$args['orderby'] = ($fields[$args['orderby']]['type'] === 'number')
? 'meta_value_num'
: 'meta_value';
}
}
$criteria = array_merge($default_args, $args);
return Post\Factory::createMultiple(get_posts($criteria), $load_terms);
} | php | public static function getWhere($args = array(), $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
// Allow sorting both by core fields and custom fields
// See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
$default_orderby = $instance->getDefaultOrderBy();
$default_order = $instance->getDefaultOrder();
$default_args = array(
'post_type' => $instance->getPostType(),
'numberposts'=> -1,
'orderby' => $default_orderby,
'order' => $default_order,
);
// Sometimes you will specify a default orderby using getDefaultOrderBy
if ($default_orderby !== 'menu_order') {
$fields = $instance->getFields();
if (array_key_exists($default_orderby, $fields)) {
$default_args['meta_key'] = $default_orderby;
// Number fields should be sorted numerically, not alphabetically
// Of course, this currently requires you to use type=number to achieve numeric sorting
$default_args['orderby'] = ($fields[$default_orderby]['type'] === 'number')
? 'meta_value_num'
: 'meta_value';
}
}
// But other times, you'll just pass in orderby via $args,
// e.g. if you call getBy or getWhere with the $args param
if (array_key_exists('orderby', $args)) {
$fields = $instance->getFields();
if (array_key_exists($args['orderby'], $fields)) {
$args['meta_key'] = $args['orderby'];
// Number fields should be sorted numerically, not alphabetically
// Of course, this currently requires you to use type=number to achieve numeric sorting
$args['orderby'] = ($fields[$args['orderby']]['type'] === 'number')
? 'meta_value_num'
: 'meta_value';
}
}
$criteria = array_merge($default_args, $args);
return Post\Factory::createMultiple(get_posts($criteria), $load_terms);
} | [
"public",
"static",
"function",
"getWhere",
"(",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"instance",
"=",
"Post",
"\\",
"Factory",
"::",
"create",
"(",
"get_called_class",
"(",
")",
")",
";",
"// Allow s... | Get posts with conditions
@param array $args
@param bool $load_terms
@return array | [
"Get",
"posts",
"with",
"conditions"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1147-L1193 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getByTerm | public static function getByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true)
{
$args = array_merge($args, array(
'tax_query'=>array(
array(
'taxonomy'=>$taxonomy,
'terms'=>$terms,
'field'=>$field
)
),
));
return static::getWhere($args, $load_terms);
} | php | public static function getByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true)
{
$args = array_merge($args, array(
'tax_query'=>array(
array(
'taxonomy'=>$taxonomy,
'terms'=>$terms,
'field'=>$field
)
),
));
return static::getWhere($args, $load_terms);
} | [
"public",
"static",
"function",
"getByTerm",
"(",
"$",
"taxonomy",
",",
"$",
"terms",
",",
"$",
"field",
"=",
"'slug'",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"args",
"=",
"array_merge",
"(",
"... | Get by a taxonomy and term
@param string $taxonomy
@param mixed $terms
@param string $field
@param array $args
@param bool $load_terms
@return array | [
"Get",
"by",
"a",
"taxonomy",
"and",
"term"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1423-L1435 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getOneByTerm | public static function getOneByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true)
{
$args['numberposts'] = 1;
$result = static::getByTerm($taxonomy, $terms, $field, $args, $load_terms);
return (count($result)) ? current($result) : null;
} | php | public static function getOneByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true)
{
$args['numberposts'] = 1;
$result = static::getByTerm($taxonomy, $terms, $field, $args, $load_terms);
return (count($result)) ? current($result) : null;
} | [
"public",
"static",
"function",
"getOneByTerm",
"(",
"$",
"taxonomy",
",",
"$",
"terms",
",",
"$",
"field",
"=",
"'slug'",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"args",
"[",
"'numberposts'",
"]"... | Get one by a taxonomy and term
@param string $taxonomy
@param mixed $terms
@param string $field
@param array $args
@param bool $load_terms
@return object | [
"Get",
"one",
"by",
"a",
"taxonomy",
"and",
"term"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1447-L1452 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPage | public static function getPage($page = 1, $args = array(), $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
$criteria = array(
'post_type' => $instance->getPostType(),
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => $instance->getPostsPerPage(),
'offset' => ($page - 1) * $instance->getPostsPerPage()
);
$criteria = array_merge($criteria, $args);
return Post\Factory::createMultiple(get_posts($criteria), $load_terms);
} | php | public static function getPage($page = 1, $args = array(), $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
$criteria = array(
'post_type' => $instance->getPostType(),
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => $instance->getPostsPerPage(),
'offset' => ($page - 1) * $instance->getPostsPerPage()
);
$criteria = array_merge($criteria, $args);
return Post\Factory::createMultiple(get_posts($criteria), $load_terms);
} | [
"public",
"static",
"function",
"getPage",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"instance",
"=",
"Post",
"\\",
"Factory",
"::",
"create",
"(",
"get_called_class",
"(... | Get results by page
@param int $page
@param array $args
@param string $sort
@param bool $load_terms | [
"Get",
"results",
"by",
"page"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1462-L1475 | train |
tacowordpress/tacowordpress | src/Post.php | Post.setTerms | public function setTerms($term_ids, $taxonomy = null, $append = false)
{
$taxonomy = ($taxonomy) ? $taxonomy : 'post_tag';
if (!is_array($this->_terms)) {
$this->_terms = array();
}
if (!array_key_exists($taxonomy, $this->_terms)) {
$this->_terms[$taxonomy] = array();
}
$this->_terms[$taxonomy] = ($append)
? array_merge($this->_terms[$taxonomy], $term_ids)
: $term_ids;
return $this->_terms[$taxonomy];
} | php | public function setTerms($term_ids, $taxonomy = null, $append = false)
{
$taxonomy = ($taxonomy) ? $taxonomy : 'post_tag';
if (!is_array($this->_terms)) {
$this->_terms = array();
}
if (!array_key_exists($taxonomy, $this->_terms)) {
$this->_terms[$taxonomy] = array();
}
$this->_terms[$taxonomy] = ($append)
? array_merge($this->_terms[$taxonomy], $term_ids)
: $term_ids;
return $this->_terms[$taxonomy];
} | [
"public",
"function",
"setTerms",
"(",
"$",
"term_ids",
",",
"$",
"taxonomy",
"=",
"null",
",",
"$",
"append",
"=",
"false",
")",
"{",
"$",
"taxonomy",
"=",
"(",
"$",
"taxonomy",
")",
"?",
"$",
"taxonomy",
":",
"'post_tag'",
";",
"if",
"(",
"!",
"i... | Set the terms
@param array $term_ids
@param string $taxonomy
@param bool $append
@return array | [
"Set",
"the",
"terms"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1533-L1547 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getTerms | public function getTerms($taxonomy = null)
{
if ($taxonomy) {
return (array_key_exists($taxonomy, $this->_terms))
? $this->_terms[$taxonomy]
: array();
}
return $this->_terms;
} | php | public function getTerms($taxonomy = null)
{
if ($taxonomy) {
return (array_key_exists($taxonomy, $this->_terms))
? $this->_terms[$taxonomy]
: array();
}
return $this->_terms;
} | [
"public",
"function",
"getTerms",
"(",
"$",
"taxonomy",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"taxonomy",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"taxonomy",
",",
"$",
"this",
"->",
"_terms",
")",
")",
"?",
"$",
"this",
"->",
"_terms"... | Get the terms
@param string $taxonomy
@return array | [
"Get",
"the",
"terms"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1555-L1564 | train |
tacowordpress/tacowordpress | src/Post.php | Post.hasTerm | public function hasTerm($term_id)
{
$taxonomy_terms = $this->getTerms();
if (!Arr::iterable($taxonomy_terms)) {
return false;
}
foreach ($taxonomy_terms as $taxonomy_key => $terms) {
if (!Arr::iterable($terms)) {
continue;
}
foreach ($terms as $term) {
if ((int) $term->term_id === (int) $term_id) {
return true;
}
}
}
return false;
} | php | public function hasTerm($term_id)
{
$taxonomy_terms = $this->getTerms();
if (!Arr::iterable($taxonomy_terms)) {
return false;
}
foreach ($taxonomy_terms as $taxonomy_key => $terms) {
if (!Arr::iterable($terms)) {
continue;
}
foreach ($terms as $term) {
if ((int) $term->term_id === (int) $term_id) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"hasTerm",
"(",
"$",
"term_id",
")",
"{",
"$",
"taxonomy_terms",
"=",
"$",
"this",
"->",
"getTerms",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"taxonomy_terms",
")",
")",
"{",
"return",
"false",
";",
"}",... | Does this post have this term?
@param integer $term_id
@return bool | [
"Does",
"this",
"post",
"have",
"this",
"term?"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1572-L1592 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPostAttachment | public function getPostAttachment($size = 'full', $property = null)
{
$post_id = $this->get('ID');
if (!has_post_thumbnail($post_id)) {
return false;
}
$attachment_id = get_post_thumbnail_id($post_id);
$image_properties = array(
'url',
'width',
'height',
'is_resized'
);
$image_array = array_combine(
$image_properties,
array_values(wp_get_attachment_image_src($attachment_id, $size))
);
if (in_array($property, $image_properties)) {
return $image_array[$property];
}
return $image_array;
} | php | public function getPostAttachment($size = 'full', $property = null)
{
$post_id = $this->get('ID');
if (!has_post_thumbnail($post_id)) {
return false;
}
$attachment_id = get_post_thumbnail_id($post_id);
$image_properties = array(
'url',
'width',
'height',
'is_resized'
);
$image_array = array_combine(
$image_properties,
array_values(wp_get_attachment_image_src($attachment_id, $size))
);
if (in_array($property, $image_properties)) {
return $image_array[$property];
}
return $image_array;
} | [
"public",
"function",
"getPostAttachment",
"(",
"$",
"size",
"=",
"'full'",
",",
"$",
"property",
"=",
"null",
")",
"{",
"$",
"post_id",
"=",
"$",
"this",
"->",
"get",
"(",
"'ID'",
")",
";",
"if",
"(",
"!",
"has_post_thumbnail",
"(",
"$",
"post_id",
... | Get the image attachment array for post's featured image
@param string $size
@param string $property
@return array or string | [
"Get",
"the",
"image",
"attachment",
"array",
"for",
"post",
"s",
"featured",
"image"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1698-L1720 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getRenderPublicField | public function getRenderPublicField($key, $field = null, $load_value = true)
{
$class = get_called_class();
if ($key === self::KEY_CLASS) {
$attribs = array('type'=>'hidden', 'name'=>$key, 'value'=>$class);
return Html::tag('input', null, $attribs);
}
if ($key === self::KEY_NONCE) {
$attribs = array('type'=>'hidden', 'name'=>$key, 'value'=>wp_create_nonce($this->getNonceAction()));
return Html::tag('input', null, $attribs);
}
if ($load_value) {
if (!is_array($field)) {
$field = self::getField($key);
}
if (!array_key_exists('value', $field)) {
$field['value'] = $this->$key;
}
}
return self::getRenderMetaBoxField($key, $field);
} | php | public function getRenderPublicField($key, $field = null, $load_value = true)
{
$class = get_called_class();
if ($key === self::KEY_CLASS) {
$attribs = array('type'=>'hidden', 'name'=>$key, 'value'=>$class);
return Html::tag('input', null, $attribs);
}
if ($key === self::KEY_NONCE) {
$attribs = array('type'=>'hidden', 'name'=>$key, 'value'=>wp_create_nonce($this->getNonceAction()));
return Html::tag('input', null, $attribs);
}
if ($load_value) {
if (!is_array($field)) {
$field = self::getField($key);
}
if (!array_key_exists('value', $field)) {
$field['value'] = $this->$key;
}
}
return self::getRenderMetaBoxField($key, $field);
} | [
"public",
"function",
"getRenderPublicField",
"(",
"$",
"key",
",",
"$",
"field",
"=",
"null",
",",
"$",
"load_value",
"=",
"true",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"$",
"key",
"===",
"self",
"::",
"KEY_CLASS",... | Render a public field
@param string $key See code below for accepted vals
@param array $field
@param bool $load_value
@return string | [
"Render",
"a",
"public",
"field"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1783-L1804 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getPublicFormKey | public function getPublicFormKey($suffix = null)
{
$val = sprintf('%s_public_form', $this->getPostType());
return ($suffix) ? sprintf('%s_%s', $val, $suffix) : $val;
} | php | public function getPublicFormKey($suffix = null)
{
$val = sprintf('%s_public_form', $this->getPostType());
return ($suffix) ? sprintf('%s_%s', $val, $suffix) : $val;
} | [
"public",
"function",
"getPublicFormKey",
"(",
"$",
"suffix",
"=",
"null",
")",
"{",
"$",
"val",
"=",
"sprintf",
"(",
"'%s_public_form'",
",",
"$",
"this",
"->",
"getPostType",
"(",
")",
")",
";",
"return",
"(",
"$",
"suffix",
")",
"?",
"sprintf",
"(",... | Get the public form key
This is useful for integrations with FlashData and the like
when you want to persist data from the form to another page.
For instance, in the case of error messages and form values.
@param string $suffix
@return string | [
"Get",
"the",
"public",
"form",
"key",
"This",
"is",
"useful",
"for",
"integrations",
"with",
"FlashData",
"and",
"the",
"like",
"when",
"you",
"want",
"to",
"persist",
"data",
"from",
"the",
"form",
"to",
"another",
"page",
".",
"For",
"instance",
"in",
... | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1841-L1845 | train |
tacowordpress/tacowordpress | src/Post.php | Post.find | public static function find($post_id, $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
$instance->load($post_id, $load_terms);
return $instance;
} | php | public static function find($post_id, $load_terms = true)
{
$instance = Post\Factory::create(get_called_class());
$instance->load($post_id, $load_terms);
return $instance;
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"post_id",
",",
"$",
"load_terms",
"=",
"true",
")",
"{",
"$",
"instance",
"=",
"Post",
"\\",
"Factory",
"::",
"create",
"(",
"get_called_class",
"(",
")",
")",
";",
"$",
"instance",
"->",
"load",
"(",
... | Find a post
@param integer $post_id
@return object | [
"Find",
"a",
"post"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1878-L1883 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getLinkURL | public function getLinkURL($field)
{
$link_attr = self::decodeLinkObject($this->get($field));
if(!is_object($link_attr)) {
return $this->get($field);
}
if(!(strlen($link_attr->href) && strlen($link_attr->title) && strlen($link_attr->target))) {
$field_attribs = $this->getField($field);
if (array_key_exists('default', $field_attribs)) return $field_attribs['default'];
}
return $link_attr->href;
} | php | public function getLinkURL($field)
{
$link_attr = self::decodeLinkObject($this->get($field));
if(!is_object($link_attr)) {
return $this->get($field);
}
if(!(strlen($link_attr->href) && strlen($link_attr->title) && strlen($link_attr->target))) {
$field_attribs = $this->getField($field);
if (array_key_exists('default', $field_attribs)) return $field_attribs['default'];
}
return $link_attr->href;
} | [
"public",
"function",
"getLinkURL",
"(",
"$",
"field",
")",
"{",
"$",
"link_attr",
"=",
"self",
"::",
"decodeLinkObject",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"field",
")",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"link_attr",
")",
")",
... | Get just the URL from a field type of link
@param string $field
@return string | [
"Get",
"just",
"the",
"URL",
"from",
"a",
"field",
"type",
"of",
"link"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1913-L1925 | train |
tacowordpress/tacowordpress | src/Post.php | Post.linkAttribsToHTMLString | public function linkAttribsToHTMLString($link_attr, $body = '', $classes = '', $id = '', $styles = '')
{
$link_text = null;
if (strlen($link_attr->title)) {
$link_text = $link_attr->title;
} elseif (strlen($body)) {
$link_text = $body;
} else {
$link_text = $link_attr->href;
}
return Html::link(
$link_attr->href,
$link_text,
array(
'title' => $link_attr->title,
'target' => $link_attr->target,
'class' => $classes,
'id' => $id,
'style' => $styles
)
);
} | php | public function linkAttribsToHTMLString($link_attr, $body = '', $classes = '', $id = '', $styles = '')
{
$link_text = null;
if (strlen($link_attr->title)) {
$link_text = $link_attr->title;
} elseif (strlen($body)) {
$link_text = $body;
} else {
$link_text = $link_attr->href;
}
return Html::link(
$link_attr->href,
$link_text,
array(
'title' => $link_attr->title,
'target' => $link_attr->target,
'class' => $classes,
'id' => $id,
'style' => $styles
)
);
} | [
"public",
"function",
"linkAttribsToHTMLString",
"(",
"$",
"link_attr",
",",
"$",
"body",
"=",
"''",
",",
"$",
"classes",
"=",
"''",
",",
"$",
"id",
"=",
"''",
",",
"$",
"styles",
"=",
"''",
")",
"{",
"$",
"link_text",
"=",
"null",
";",
"if",
"(",
... | Get an HTML link from attributes that come from a link object
This is mainly used with the field type of link
@param object $link_attr
@param string $body
@param string $classes
@param string $id
@param string $styles
@return string | [
"Get",
"an",
"HTML",
"link",
"from",
"attributes",
"that",
"come",
"from",
"a",
"link",
"object",
"This",
"is",
"mainly",
"used",
"with",
"the",
"field",
"type",
"of",
"link"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L1954-L1975 | train |
tacowordpress/tacowordpress | src/Post.php | Post.getLinkHTMLFromObject | public static function getLinkHTMLFromObject($object_string, $body = '', $classes = '', $id = '', $styles = '')
{
return self::linkAttribsToHTMLString(
self::decodeLinkObject($object_string),
$body,
$classes,
$id,
$styles
);
} | php | public static function getLinkHTMLFromObject($object_string, $body = '', $classes = '', $id = '', $styles = '')
{
return self::linkAttribsToHTMLString(
self::decodeLinkObject($object_string),
$body,
$classes,
$id,
$styles
);
} | [
"public",
"static",
"function",
"getLinkHTMLFromObject",
"(",
"$",
"object_string",
",",
"$",
"body",
"=",
"''",
",",
"$",
"classes",
"=",
"''",
",",
"$",
"id",
"=",
"''",
",",
"$",
"styles",
"=",
"''",
")",
"{",
"return",
"self",
"::",
"linkAttribsToH... | Get an HTML link from an encoded link object
@param string $oject_string
@param string $body
@param string $classes
@param string $id
@param string $styles
@return string | [
"Get",
"an",
"HTML",
"link",
"from",
"an",
"encoded",
"link",
"object"
] | eedcc0df5ec5293b9c1b62a698ba3d9f9230b528 | https://github.com/tacowordpress/tacowordpress/blob/eedcc0df5ec5293b9c1b62a698ba3d9f9230b528/src/Post.php#L2006-L2015 | train |
Whyounes/laravel-passwordless-auth | src/Traits/Passwordless.php | Passwordless.generateToken | public function generateToken($save = false)
{
$attributes = [
'token' => str_random(16),
'is_used' => false,
'user_id' => $this->id,
'created_at' => time()
];
$token = App::make(Token::class);
$token->fill($attributes);
if ($save) {
$token->save();
}
return $token;
} | php | public function generateToken($save = false)
{
$attributes = [
'token' => str_random(16),
'is_used' => false,
'user_id' => $this->id,
'created_at' => time()
];
$token = App::make(Token::class);
$token->fill($attributes);
if ($save) {
$token->save();
}
return $token;
} | [
"public",
"function",
"generateToken",
"(",
"$",
"save",
"=",
"false",
")",
"{",
"$",
"attributes",
"=",
"[",
"'token'",
"=>",
"str_random",
"(",
"16",
")",
",",
"'is_used'",
"=>",
"false",
",",
"'user_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'create... | Generate a token for the current user.
@param bool $save Generate token and save it.
@return Token | [
"Generate",
"a",
"token",
"for",
"the",
"current",
"user",
"."
] | 0cfbdfede2f2fcca950355e420ff13e51236ed5f | https://github.com/Whyounes/laravel-passwordless-auth/blob/0cfbdfede2f2fcca950355e420ff13e51236ed5f/src/Traits/Passwordless.php#L51-L67 | train |
Opifer/Cms | src/ExpressionEngine/Visitor/QueryBuilderVisitor.php | QueryBuilderVisitor.enterExpression | public function enterExpression(Expression $expr)
{
$hash = spl_object_hash($expr);
if ($expr instanceof Key) {
if (!count($this->hashes)) {
$this->qb->andWhere($this->toExpr($expr));
} else {
$lastHash = end($this->hashes);
$this->map[$lastHash][] = $this->toExpr($expr);
}
} elseif ($expr instanceof OrX) {
$this->hashes[] = $hash;
$this->map[$hash] = [];
} elseif ($expr instanceof AndX) {
$this->hashes[] = $hash;
$this->map[$hash] = [];
}
return $expr;
} | php | public function enterExpression(Expression $expr)
{
$hash = spl_object_hash($expr);
if ($expr instanceof Key) {
if (!count($this->hashes)) {
$this->qb->andWhere($this->toExpr($expr));
} else {
$lastHash = end($this->hashes);
$this->map[$lastHash][] = $this->toExpr($expr);
}
} elseif ($expr instanceof OrX) {
$this->hashes[] = $hash;
$this->map[$hash] = [];
} elseif ($expr instanceof AndX) {
$this->hashes[] = $hash;
$this->map[$hash] = [];
}
return $expr;
} | [
"public",
"function",
"enterExpression",
"(",
"Expression",
"$",
"expr",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"expr",
")",
";",
"if",
"(",
"$",
"expr",
"instanceof",
"Key",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->"... | Adds `Key` expressions to the query or stores children of OrX and AndX expressions in memory to be added
on the leaveExpression for OrX or AndX expressions.
{@inheritdoc} | [
"Adds",
"Key",
"expressions",
"to",
"the",
"query",
"or",
"stores",
"children",
"of",
"OrX",
"and",
"AndX",
"expressions",
"in",
"memory",
"to",
"be",
"added",
"on",
"the",
"leaveExpression",
"for",
"OrX",
"or",
"AndX",
"expressions",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/Visitor/QueryBuilderVisitor.php#L60-L81 | train |
Opifer/Cms | src/ExpressionEngine/Visitor/QueryBuilderVisitor.php | QueryBuilderVisitor.leaveExpression | public function leaveExpression(Expression $expr)
{
if ($expr instanceof OrX || $expr instanceof AndX) {
$hash = spl_object_hash($expr);
if ($expr instanceof OrX) {
$composite = $this->qb->expr()->orX();
$composite->addMultiple($this->map[$hash]);
} else {
$composite = $this->qb->expr()->andX();
$composite->addMultiple($this->map[$hash]);
}
unset($this->hashes[array_search($hash, $this->hashes)]);
if (!count($this->hashes)) {
$this->qb->andWhere($composite);
} else {
$lastHash = end($this->hashes);
$this->map[$lastHash][] = $composite;
}
}
return $expr;
} | php | public function leaveExpression(Expression $expr)
{
if ($expr instanceof OrX || $expr instanceof AndX) {
$hash = spl_object_hash($expr);
if ($expr instanceof OrX) {
$composite = $this->qb->expr()->orX();
$composite->addMultiple($this->map[$hash]);
} else {
$composite = $this->qb->expr()->andX();
$composite->addMultiple($this->map[$hash]);
}
unset($this->hashes[array_search($hash, $this->hashes)]);
if (!count($this->hashes)) {
$this->qb->andWhere($composite);
} else {
$lastHash = end($this->hashes);
$this->map[$lastHash][] = $composite;
}
}
return $expr;
} | [
"public",
"function",
"leaveExpression",
"(",
"Expression",
"$",
"expr",
")",
"{",
"if",
"(",
"$",
"expr",
"instanceof",
"OrX",
"||",
"$",
"expr",
"instanceof",
"AndX",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"expr",
")",
";",
"if",
"(... | Adds the AndX and OrX Doctrine expressions to the query
{@inheritdoc} | [
"Adds",
"the",
"AndX",
"and",
"OrX",
"Doctrine",
"expressions",
"to",
"the",
"query"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/Visitor/QueryBuilderVisitor.php#L88-L113 | train |
Opifer/Cms | src/ExpressionEngine/Visitor/QueryBuilderVisitor.php | QueryBuilderVisitor.shouldJoin | public function shouldJoin($key, $prefix = null)
{
$parts = explode('.', $key);
if (!$prefix) {
$prefix = $this->getRootAlias();
}
if (!in_array($parts[0], $this->qb->getAllAliases())) {
$this->qb->leftJoin($prefix.'.'.$parts[0], $parts[0]);
}
// If the key consists of multiple . parts, we also need to add joins for the other parts
if (count($parts) > 2) {
$prefix = array_shift($parts);
$leftover = implode('.', $parts);
$key = $this->shouldJoin($leftover, $prefix);
}
return $key;
} | php | public function shouldJoin($key, $prefix = null)
{
$parts = explode('.', $key);
if (!$prefix) {
$prefix = $this->getRootAlias();
}
if (!in_array($parts[0], $this->qb->getAllAliases())) {
$this->qb->leftJoin($prefix.'.'.$parts[0], $parts[0]);
}
// If the key consists of multiple . parts, we also need to add joins for the other parts
if (count($parts) > 2) {
$prefix = array_shift($parts);
$leftover = implode('.', $parts);
$key = $this->shouldJoin($leftover, $prefix);
}
return $key;
} | [
"public",
"function",
"shouldJoin",
"(",
"$",
"key",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"prefix",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",... | Strips the key parts and creates joins if they don't exist yet.
@param string $key A lowercase dot-separated key. e.g. "content.template.id"
@return string The final key that can be used in e.g. WHERE statements | [
"Strips",
"the",
"key",
"parts",
"and",
"creates",
"joins",
"if",
"they",
"don",
"t",
"exist",
"yet",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/Visitor/QueryBuilderVisitor.php#L187-L207 | train |
aegis-security/JWT | src/Signer/Rsa.php | Rsa.validateKey | private function validateKey($key)
{
$details = openssl_pkey_get_details($key);
if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) {
throw new \InvalidArgumentException('This key is not compatible with RSA signatures');
}
} | php | private function validateKey($key)
{
$details = openssl_pkey_get_details($key);
if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) {
throw new \InvalidArgumentException('This key is not compatible with RSA signatures');
}
} | [
"private",
"function",
"validateKey",
"(",
"$",
"key",
")",
"{",
"$",
"details",
"=",
"openssl_pkey_get_details",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"details",
"[",
"'key'",
"]",
")",
"||",
"$",
"details",
"[",
"'type'",
"]... | Returns if the key type is equals with expected type
@param resource $key
@return boolean | [
"Returns",
"if",
"the",
"key",
"type",
"is",
"equals",
"with",
"expected",
"type"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signer/Rsa.php#L47-L54 | train |
Opifer/Cms | src/ContentBundle/Block/Service/DownloadsBlockService.php | DownloadsBlockService.downloadMediaAction | public function downloadMediaAction($filename)
{
$media = $this->mediaManager->getRepository()->findOneByReference($filename);
$provider = $this->container->get('opifer.media.provider.pool')->getProvider($media->getProvider());
$mediaUrl = $provider->getUrl($media);
$fileSystem = $provider->getFileSystem();
$file = $fileSystem->read($media->getReference());
$response = new Response();
$response->headers->set('Content-type', $media->getContentType());
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', basename($mediaUrl)));
$response->setContent($file);
return $response;
} | php | public function downloadMediaAction($filename)
{
$media = $this->mediaManager->getRepository()->findOneByReference($filename);
$provider = $this->container->get('opifer.media.provider.pool')->getProvider($media->getProvider());
$mediaUrl = $provider->getUrl($media);
$fileSystem = $provider->getFileSystem();
$file = $fileSystem->read($media->getReference());
$response = new Response();
$response->headers->set('Content-type', $media->getContentType());
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', basename($mediaUrl)));
$response->setContent($file);
return $response;
} | [
"public",
"function",
"downloadMediaAction",
"(",
"$",
"filename",
")",
"{",
"$",
"media",
"=",
"$",
"this",
"->",
"mediaManager",
"->",
"getRepository",
"(",
")",
"->",
"findOneByReference",
"(",
"$",
"filename",
")",
";",
"$",
"provider",
"=",
"$",
"this... | Download media item.
@param string $filename
@return Response | [
"Download",
"media",
"item",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/Service/DownloadsBlockService.php#L71-L87 | train |
Opifer/Cms | src/ContentBundle/Form/Type/DisplayLogicType.php | DisplayLogicType.getDisplayLogicPrototypes | protected function getDisplayLogicPrototypes(BlockInterface $block)
{
$collection = new PrototypeCollection([
new OrXPrototype(),
new AndXPrototype(),
new EventPrototype('click_event', 'Click Event', 'event.type.click'),
new TextPrototype('dom_node_id', 'DOM Node Id', 'node.id')
]);
$owner = $block->getOwner();
if ($owner) {
// Avoid trying to add display logic for blocks when the current block has no owner (e.g. shared blocks)
$blockChoices = [];
foreach ($owner->getBlocks() as $member) {
try {
$properties = $member->getProperties();
if ($member instanceof ChoiceFieldBlock) {
if (empty($member->getName())) {
continue;
}
if (!isset($properties['options'])) {
continue;
}
$choices = [];
foreach ($properties['options'] as $option) {
if (empty($option['key'])) {
continue;
}
$choices[] = new Choice($option['key'], $option['value']);
}
$collection->add(new SelectPrototype($member->getName(), $properties['label'], $member->getName(), $choices));
} elseif ($member instanceof NumberFieldBlock || $member instanceof RangeFieldBlock) {
if (empty($member->getName())) {
continue;
}
$collection->add(new NumberPrototype($member->getName(), $properties['label'], $member->getName()));
}
if (!empty($member->getName())) {
$blockChoices[] = new Choice($member->getName(), $member->getName());
}
} catch (\Exception $e) {
// Avoid throwing exceptions here for now, since e.g. duplicate namesthis will cause all blocks to be uneditable.
}
}
$collection->add(new SelectPrototype('block_name', 'Block Name', 'block.name', $blockChoices));
}
return $collection->all();
} | php | protected function getDisplayLogicPrototypes(BlockInterface $block)
{
$collection = new PrototypeCollection([
new OrXPrototype(),
new AndXPrototype(),
new EventPrototype('click_event', 'Click Event', 'event.type.click'),
new TextPrototype('dom_node_id', 'DOM Node Id', 'node.id')
]);
$owner = $block->getOwner();
if ($owner) {
// Avoid trying to add display logic for blocks when the current block has no owner (e.g. shared blocks)
$blockChoices = [];
foreach ($owner->getBlocks() as $member) {
try {
$properties = $member->getProperties();
if ($member instanceof ChoiceFieldBlock) {
if (empty($member->getName())) {
continue;
}
if (!isset($properties['options'])) {
continue;
}
$choices = [];
foreach ($properties['options'] as $option) {
if (empty($option['key'])) {
continue;
}
$choices[] = new Choice($option['key'], $option['value']);
}
$collection->add(new SelectPrototype($member->getName(), $properties['label'], $member->getName(), $choices));
} elseif ($member instanceof NumberFieldBlock || $member instanceof RangeFieldBlock) {
if (empty($member->getName())) {
continue;
}
$collection->add(new NumberPrototype($member->getName(), $properties['label'], $member->getName()));
}
if (!empty($member->getName())) {
$blockChoices[] = new Choice($member->getName(), $member->getName());
}
} catch (\Exception $e) {
// Avoid throwing exceptions here for now, since e.g. duplicate namesthis will cause all blocks to be uneditable.
}
}
$collection->add(new SelectPrototype('block_name', 'Block Name', 'block.name', $blockChoices));
}
return $collection->all();
} | [
"protected",
"function",
"getDisplayLogicPrototypes",
"(",
"BlockInterface",
"$",
"block",
")",
"{",
"$",
"collection",
"=",
"new",
"PrototypeCollection",
"(",
"[",
"new",
"OrXPrototype",
"(",
")",
",",
"new",
"AndXPrototype",
"(",
")",
",",
"new",
"EventPrototy... | Builds the default display condition prototypes
@param BlockInterface $block
@return \Opifer\ExpressionEngine\Prototype\Prototype[] | [
"Builds",
"the",
"default",
"display",
"condition",
"prototypes"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Form/Type/DisplayLogicType.php#L65-L117 | train |
Opifer/Cms | src/CmsBundle/Security/AuthenticationSuccessHandler.php | AuthenticationSuccessHandler.onAuthenticationSuccess | public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
if ($user = $token->getUser()) {
if (!$user->getFirstName() || !$user->getLastName()) {
return new RedirectResponse($this->router->generate('opifer_cms_user_profile'));
}
}
return parent::onAuthenticationSuccess($request, $token);
} | php | public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
if ($user = $token->getUser()) {
if (!$user->getFirstName() || !$user->getLastName()) {
return new RedirectResponse($this->router->generate('opifer_cms_user_profile'));
}
}
return parent::onAuthenticationSuccess($request, $token);
} | [
"public",
"function",
"onAuthenticationSuccess",
"(",
"Request",
"$",
"request",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"user",
"=",
"$",
"token",
"->",
"getUser",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"user",
"->",
"getFirst... | Checks if the user has actually filled in some mandatory data. If not, it redirects to the users'
profile page.
{@inheritdoc} | [
"Checks",
"if",
"the",
"user",
"has",
"actually",
"filled",
"in",
"some",
"mandatory",
"data",
".",
"If",
"not",
"it",
"redirects",
"to",
"the",
"users",
"profile",
"page",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Security/AuthenticationSuccessHandler.php#L37-L46 | train |
aegis-security/JWT | src/Transformer/Deserializer.php | Deserializer.fromBase64URL | public function fromBase64URL($data)
{
if ($remainder = strlen($data) % 4) {
$data .= str_repeat('=', 4 - $remainder);
}
return base64_decode(strtr($data, '-_', '+/'));
} | php | public function fromBase64URL($data)
{
if ($remainder = strlen($data) % 4) {
$data .= str_repeat('=', 4 - $remainder);
}
return base64_decode(strtr($data, '-_', '+/'));
} | [
"public",
"function",
"fromBase64URL",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"remainder",
"=",
"strlen",
"(",
"$",
"data",
")",
"%",
"4",
")",
"{",
"$",
"data",
".=",
"str_repeat",
"(",
"'='",
",",
"4",
"-",
"$",
"remainder",
")",
";",
"}",... | Deserializes from base64url
@param string $data
@return string | [
"Deserializes",
"from",
"base64url"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Transformer/Deserializer.php#L39-L46 | train |
Opifer/Cms | src/MailingListBundle/Provider/MailPlusProvider.php | MailPlusProvider.synchronise | public function synchronise(Subscription $subscription)
{
try {
$contact = [
'update' => true,
'purge' => false,
'contact' => [
'externalId' => $subscription->getId(),
'properties' => [
'email' => $subscription->getEmail(),
],
],
];
$response = $this->post('contact', $contact);
if ($response->getStatusCode() == '204') { //Contact added successfully status code
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_SYNCED);
return true;
} else {
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);
return false;
}
} catch (\Exception $e) {
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);
return true;
}
} | php | public function synchronise(Subscription $subscription)
{
try {
$contact = [
'update' => true,
'purge' => false,
'contact' => [
'externalId' => $subscription->getId(),
'properties' => [
'email' => $subscription->getEmail(),
],
],
];
$response = $this->post('contact', $contact);
if ($response->getStatusCode() == '204') { //Contact added successfully status code
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_SYNCED);
return true;
} else {
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);
return false;
}
} catch (\Exception $e) {
$this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);
return true;
}
} | [
"public",
"function",
"synchronise",
"(",
"Subscription",
"$",
"subscription",
")",
"{",
"try",
"{",
"$",
"contact",
"=",
"[",
"'update'",
"=>",
"true",
",",
"'purge'",
"=>",
"false",
",",
"'contact'",
"=>",
"[",
"'externalId'",
"=>",
"$",
"subscription",
... | Synchronize a subscription
@param Subscription $subscription
@return bool | [
"Synchronize",
"a",
"subscription"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Provider/MailPlusProvider.php#L46-L76 | train |
aegis-security/JWT | src/Token.php | Token.getHeader | public function getHeader($name, $default = null)
{
if ($this->hasHeader($name)) {
return $this->getHeaderValue($name);
}
if ($default === null) {
throw new \OutOfBoundsException('Requested header is not configured');
}
return $default;
} | php | public function getHeader($name, $default = null)
{
if ($this->hasHeader($name)) {
return $this->getHeaderValue($name);
}
if ($default === null) {
throw new \OutOfBoundsException('Requested header is not configured');
}
return $default;
} | [
"public",
"function",
"getHeader",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasHeader",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getHeaderValue",
"(",
"$",
"name",
")",
";",
... | Returns the value of a token header
@param string $name
@param mixed $default
@return mixed
@throws \OutOfBoundsException | [
"Returns",
"the",
"value",
"of",
"a",
"token",
"header"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L98-L109 | train |
aegis-security/JWT | src/Token.php | Token.getHeaderValue | private function getHeaderValue($name)
{
$header = $this->headers[$name];
if ($header instanceof Claim) {
return $header->getValue();
}
return $header;
} | php | private function getHeaderValue($name)
{
$header = $this->headers[$name];
if ($header instanceof Claim) {
return $header->getValue();
}
return $header;
} | [
"private",
"function",
"getHeaderValue",
"(",
"$",
"name",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"header",
"instanceof",
"Claim",
")",
"{",
"return",
"$",
"header",
"->",
"getValue",
"... | Returns the value stored in header
@param string $name
@return mixed | [
"Returns",
"the",
"value",
"stored",
"in",
"header"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L118-L127 | train |
aegis-security/JWT | src/Token.php | Token.getClaim | public function getClaim($name, $default = null)
{
if ($this->hasClaim($name)) {
return $this->claims[$name]->getValue();
}
if ($default === null) {
throw new \OutOfBoundsException('Requested claim is not configured');
}
return $default;
} | php | public function getClaim($name, $default = null)
{
if ($this->hasClaim($name)) {
return $this->claims[$name]->getValue();
}
if ($default === null) {
throw new \OutOfBoundsException('Requested claim is not configured');
}
return $default;
} | [
"public",
"function",
"getClaim",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasClaim",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"claims",
"[",
"$",
"name",
"]",
"->",
"getVal... | Returns the value of a token claim
@param string $name
@param mixed $default
@return mixed
@throws \OutOfBoundsException | [
"Returns",
"the",
"value",
"of",
"a",
"token",
"claim"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L161-L172 | train |
aegis-security/JWT | src/Token.php | Token.verify | public function verify(Signer $signer, $key)
{
if ($this->signature === null) {
throw new \BadMethodCallException('This token is not signed');
}
if ($this->headers['alg'] !== $signer->getAlgorithmId()) {
return false;
}
return $this->signature->verify($signer, $this->getPayload(), $key);
} | php | public function verify(Signer $signer, $key)
{
if ($this->signature === null) {
throw new \BadMethodCallException('This token is not signed');
}
if ($this->headers['alg'] !== $signer->getAlgorithmId()) {
return false;
}
return $this->signature->verify($signer, $this->getPayload(), $key);
} | [
"public",
"function",
"verify",
"(",
"Signer",
"$",
"signer",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"signature",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'This token is not signed'",
")",
";",
"}",
... | Verify if the key matches with the one that created the signature
@param Signer $signer
@param string $key
@return boolean
@throws \BadMethodCallException When token is not signed | [
"Verify",
"if",
"the",
"key",
"matches",
"with",
"the",
"one",
"that",
"created",
"the",
"signature"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L184-L195 | train |
aegis-security/JWT | src/Token.php | Token.validate | public function validate(ValidationData $data)
{
foreach ($this->getValidatableClaims() as $claim) {
if (!$claim->validate($data)) {
return false;
}
}
return true;
} | php | public function validate(ValidationData $data)
{
foreach ($this->getValidatableClaims() as $claim) {
if (!$claim->validate($data)) {
return false;
}
}
return true;
} | [
"public",
"function",
"validate",
"(",
"ValidationData",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getValidatableClaims",
"(",
")",
"as",
"$",
"claim",
")",
"{",
"if",
"(",
"!",
"$",
"claim",
"->",
"validate",
"(",
"$",
"data",
")",
... | Validates if the token is valid
@param ValidationData $data
@return boolean | [
"Validates",
"if",
"the",
"token",
"is",
"valid"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L204-L213 | train |
aegis-security/JWT | src/Token.php | Token.getValidatableClaims | private function getValidatableClaims()
{
$claims = array();
foreach ($this->claims as $claim) {
if ($claim instanceof Validatable) {
$cliams[] = $claim;
}
}
return $claims;
} | php | private function getValidatableClaims()
{
$claims = array();
foreach ($this->claims as $claim) {
if ($claim instanceof Validatable) {
$cliams[] = $claim;
}
}
return $claims;
} | [
"private",
"function",
"getValidatableClaims",
"(",
")",
"{",
"$",
"claims",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"claims",
"as",
"$",
"claim",
")",
"{",
"if",
"(",
"$",
"claim",
"instanceof",
"Validatable",
")",
"{",
"$",
... | Yields the validatable claims
@return array | [
"Yields",
"the",
"validatable",
"claims"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Token.php#L220-L231 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.create | public function create($projectKey, $issueTypeName)
{
$fieldsMetadata = $this->getCreateMetadataFields($projectKey, $issueTypeName);
$fluentIssueCreate = new FluentIssueCreate($this->client, $fieldsMetadata);
return $fluentIssueCreate->field(Field::PROJECT, $projectKey)
->field(Field::ISSUE_TYPE, $issueTypeName);
} | php | public function create($projectKey, $issueTypeName)
{
$fieldsMetadata = $this->getCreateMetadataFields($projectKey, $issueTypeName);
$fluentIssueCreate = new FluentIssueCreate($this->client, $fieldsMetadata);
return $fluentIssueCreate->field(Field::PROJECT, $projectKey)
->field(Field::ISSUE_TYPE, $issueTypeName);
} | [
"public",
"function",
"create",
"(",
"$",
"projectKey",
",",
"$",
"issueTypeName",
")",
"{",
"$",
"fieldsMetadata",
"=",
"$",
"this",
"->",
"getCreateMetadataFields",
"(",
"$",
"projectKey",
",",
"$",
"issueTypeName",
")",
";",
"$",
"fluentIssueCreate",
"=",
... | Creates an issue or a sub-task
@param string $projectKey
@param string $issueTypeName
@return FluentIssueCreate
@throws JiraException | [
"Creates",
"an",
"issue",
"or",
"a",
"sub",
"-",
"task"
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L32-L40 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.addComment | public function addComment($issue, $body, $visibilityType = null, $visibilityName = null, $expand = false)
{
$path = "/issue/{$issue}/comment" . ($expand ? '?expand' : '');
$data = array(
'body' => $body
);
if ($visibilityType !== null && $visibilityName !== null) {
$data['visibility'] = array(
'type' => $visibilityType,
'value' => $visibilityName
);
}
try {
$result = $this->client->callPost($path, $data);
return new Comment($this->client, $result->getData());
} catch (Exception $e) {
throw new JiraException("Failed to add comment", $e);
}
} | php | public function addComment($issue, $body, $visibilityType = null, $visibilityName = null, $expand = false)
{
$path = "/issue/{$issue}/comment" . ($expand ? '?expand' : '');
$data = array(
'body' => $body
);
if ($visibilityType !== null && $visibilityName !== null) {
$data['visibility'] = array(
'type' => $visibilityType,
'value' => $visibilityName
);
}
try {
$result = $this->client->callPost($path, $data);
return new Comment($this->client, $result->getData());
} catch (Exception $e) {
throw new JiraException("Failed to add comment", $e);
}
} | [
"public",
"function",
"addComment",
"(",
"$",
"issue",
",",
"$",
"body",
",",
"$",
"visibilityType",
"=",
"null",
",",
"$",
"visibilityName",
"=",
"null",
",",
"$",
"expand",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"\"/issue/{$issue}/comment\"",
".",
"... | Adds a new comment to an issue.
@param string $issue
@param string $body
@param string $visibilityType
@param string $visibilityName
@param boolean $expand provides body rendered in HTML
@return Comment
@throws JiraException | [
"Adds",
"a",
"new",
"comment",
"to",
"an",
"issue",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L146-L168 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.deleteComment | public function deleteComment($issue, $commentId)
{
$path = "/issue/{$issue}/comment/{$commentId}";
try {
$this->client->callDelete($path);
} catch (Exception $e) {
throw new JiraException("Failed to delete comment", $e);
}
} | php | public function deleteComment($issue, $commentId)
{
$path = "/issue/{$issue}/comment/{$commentId}";
try {
$this->client->callDelete($path);
} catch (Exception $e) {
throw new JiraException("Failed to delete comment", $e);
}
} | [
"public",
"function",
"deleteComment",
"(",
"$",
"issue",
",",
"$",
"commentId",
")",
"{",
"$",
"path",
"=",
"\"/issue/{$issue}/comment/{$commentId}\"",
";",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"callDelete",
"(",
"$",
"path",
")",
";",
"}",
"cat... | Deletes an existing comment
@param string $issue
@param int $commentId
@throws JiraException | [
"Deletes",
"an",
"existing",
"comment"
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L213-L222 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.getEditMetadata | public function getEditMetadata($issue)
{
$path = "/issue/{$issue}/editmeta";
try {
$data = $this->client->callGet($path)->getData();
if (!isset($data['fields'])) {
throw new JiraException("Bad metadata");
}
return $data;
} catch (Exception $e) {
throw new JiraException("Failed to retrieve issue metadata", $e);
}
} | php | public function getEditMetadata($issue)
{
$path = "/issue/{$issue}/editmeta";
try {
$data = $this->client->callGet($path)->getData();
if (!isset($data['fields'])) {
throw new JiraException("Bad metadata");
}
return $data;
} catch (Exception $e) {
throw new JiraException("Failed to retrieve issue metadata", $e);
}
} | [
"public",
"function",
"getEditMetadata",
"(",
"$",
"issue",
")",
"{",
"$",
"path",
"=",
"\"/issue/{$issue}/editmeta\"",
";",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"client",
"->",
"callGet",
"(",
"$",
"path",
")",
"->",
"getData",
"(",
")",
"... | Returns the meta data for editing an issue.
@param string $issue
@return type
@throws JiraException | [
"Returns",
"the",
"meta",
"data",
"for",
"editing",
"an",
"issue",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L231-L246 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.addWatcher | public function addWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers";
try {
$this->client->callPost($path, $login);
} catch (Exception $e) {
throw new JiraException("Failed to add watcher '{$login}' to issue '{$issue}'", $e);
}
return $this;
} | php | public function addWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers";
try {
$this->client->callPost($path, $login);
} catch (Exception $e) {
throw new JiraException("Failed to add watcher '{$login}' to issue '{$issue}'", $e);
}
return $this;
} | [
"public",
"function",
"addWatcher",
"(",
"$",
"issue",
",",
"$",
"login",
")",
"{",
"$",
"path",
"=",
"\"/issue/{$issue}/watchers\"",
";",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"callPost",
"(",
"$",
"path",
",",
"$",
"login",
")",
";",
"}",
... | Adds a user to an issue's watcher list.
@param string $issue
@param string $login
@return \JiraClient\Request\Issue
@throws JiraException | [
"Adds",
"a",
"user",
"to",
"an",
"issue",
"s",
"watcher",
"list",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L266-L277 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.deleteWatcher | public function deleteWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers?username={$login}";
try {
$this->client->callDelete($path);
} catch (Exception $e) {
throw new JiraException("Failed to delete watcher '{$login}' to issue '{$issue}'", $e);
}
} | php | public function deleteWatcher($issue, $login)
{
$path = "/issue/{$issue}/watchers?username={$login}";
try {
$this->client->callDelete($path);
} catch (Exception $e) {
throw new JiraException("Failed to delete watcher '{$login}' to issue '{$issue}'", $e);
}
} | [
"public",
"function",
"deleteWatcher",
"(",
"$",
"issue",
",",
"$",
"login",
")",
"{",
"$",
"path",
"=",
"\"/issue/{$issue}/watchers?username={$login}\"",
";",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"callDelete",
"(",
"$",
"path",
")",
";",
"}",
"c... | Removes a user from an issue's watcher list.
@param string $issue
@param string $login
@throws JiraException | [
"Removes",
"a",
"user",
"from",
"an",
"issue",
"s",
"watcher",
"list",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L286-L295 | train |
oRastor/jira-client | src/Request/Issue.php | Issue.get | public function get($issue, $includedFields = null, $expandFields = false)
{
$params = array();
if ($includedFields !== null) {
$params['fields'] = $includedFields;
}
if ($expandFields) {
$params['expand'] = '';
}
$path = "/issue/{$issue}?" . http_build_query($params);
$result = $this->client->callGet($path)->getData();
return new \JiraClient\Resource\Issue($this->client, $result);
} | php | public function get($issue, $includedFields = null, $expandFields = false)
{
$params = array();
if ($includedFields !== null) {
$params['fields'] = $includedFields;
}
if ($expandFields) {
$params['expand'] = '';
}
$path = "/issue/{$issue}?" . http_build_query($params);
$result = $this->client->callGet($path)->getData();
return new \JiraClient\Resource\Issue($this->client, $result);
} | [
"public",
"function",
"get",
"(",
"$",
"issue",
",",
"$",
"includedFields",
"=",
"null",
",",
"$",
"expandFields",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"includedFields",
"!==",
"null",
")",
"{",
"$",
"... | Returns a full representation of the issue for the given issue key.
@param string|int $issue the issue id or key to update
@param type $includedFields the list of fields to return for the issue. By default, all fields are returned.
@param type $expandFields
@return \JiraClient\Resource\Issue | [
"Returns",
"a",
"full",
"representation",
"of",
"the",
"issue",
"for",
"the",
"given",
"issue",
"key",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Request/Issue.php#L441-L457 | train |
phpbg/mpegts | src/Packetizer.php | Packetizer.findall | protected function findall(string $haystack, $needle): array
{
$lastPos = 0;
$positions = [];
while (($lastPos = strpos($haystack, $needle, $lastPos)) !== false) {
$positions[] = $lastPos;
$lastPos = $lastPos + 1;
}
return $positions;
} | php | protected function findall(string $haystack, $needle): array
{
$lastPos = 0;
$positions = [];
while (($lastPos = strpos($haystack, $needle, $lastPos)) !== false) {
$positions[] = $lastPos;
$lastPos = $lastPos + 1;
}
return $positions;
} | [
"protected",
"function",
"findall",
"(",
"string",
"$",
"haystack",
",",
"$",
"needle",
")",
":",
"array",
"{",
"$",
"lastPos",
"=",
"0",
";",
"$",
"positions",
"=",
"[",
"]",
";",
"while",
"(",
"(",
"$",
"lastPos",
"=",
"strpos",
"(",
"$",
"haysta... | Find all occurrences of a needle in a string
@param string $haystack The string to search in
@param mixed $needle
@return array | [
"Find",
"all",
"occurrences",
"of",
"a",
"needle",
"in",
"a",
"string"
] | 990fc1e843fb0d0b6db9f9631d8a85f0ea1c43b4 | https://github.com/phpbg/mpegts/blob/990fc1e843fb0d0b6db9f9631d8a85f0ea1c43b4/src/Packetizer.php#L140-L149 | train |
phpbg/mpegts | src/Packetizer.php | Packetizer.findFirstPacketOffset | protected function findFirstPacketOffset()
{
// This is quite ugly because it will parse the entire buffer whatever it's size is
// TODO Rewrite this in a more clever way
$positions = $this->findall($this->buffer, 'G');
while (count($positions) > 0) {
$position = array_shift($positions);
for ($i = 1; $i <= $this->consecutivePacketsBeforeLock; $i++) {
if (!in_array($position + 188 * $i, $positions)) {
break;
}
return $position;
}
}
return false;
} | php | protected function findFirstPacketOffset()
{
// This is quite ugly because it will parse the entire buffer whatever it's size is
// TODO Rewrite this in a more clever way
$positions = $this->findall($this->buffer, 'G');
while (count($positions) > 0) {
$position = array_shift($positions);
for ($i = 1; $i <= $this->consecutivePacketsBeforeLock; $i++) {
if (!in_array($position + 188 * $i, $positions)) {
break;
}
return $position;
}
}
return false;
} | [
"protected",
"function",
"findFirstPacketOffset",
"(",
")",
"{",
"// This is quite ugly because it will parse the entire buffer whatever it's size is",
"// TODO Rewrite this in a more clever way",
"$",
"positions",
"=",
"$",
"this",
"->",
"findall",
"(",
"$",
"this",
"->",
"buf... | Find the offset of the first MPEG TS packet in the current buffer
@return bool|int | [
"Find",
"the",
"offset",
"of",
"the",
"first",
"MPEG",
"TS",
"packet",
"in",
"the",
"current",
"buffer"
] | 990fc1e843fb0d0b6db9f9631d8a85f0ea1c43b4 | https://github.com/phpbg/mpegts/blob/990fc1e843fb0d0b6db9f9631d8a85f0ea1c43b4/src/Packetizer.php#L156-L171 | train |
Konafets/typo3_debugbar | Classes/DataCollectors/BaseCollector.php | BaseCollector.extGetLL | protected function extGetLL($key, $convertWithHtmlspecialchars = true)
{
$labelStr = $this->getLanguageService()->getLL($key);
if ($convertWithHtmlspecialchars) {
$labelStr = htmlspecialchars($labelStr);
}
return $labelStr;
} | php | protected function extGetLL($key, $convertWithHtmlspecialchars = true)
{
$labelStr = $this->getLanguageService()->getLL($key);
if ($convertWithHtmlspecialchars) {
$labelStr = htmlspecialchars($labelStr);
}
return $labelStr;
} | [
"protected",
"function",
"extGetLL",
"(",
"$",
"key",
",",
"$",
"convertWithHtmlspecialchars",
"=",
"true",
")",
"{",
"$",
"labelStr",
"=",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
"->",
"getLL",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"co... | Translate given key
@param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/Resources/Private/Language/locallang_tsfe.xlf
@param bool $convertWithHtmlspecialchars If TRUE the language-label will be sent through htmlspecialchars
@return string The value for the $key | [
"Translate",
"given",
"key"
] | cc9b168d38994652c5b077617d7f46ad164cb31d | https://github.com/Konafets/typo3_debugbar/blob/cc9b168d38994652c5b077617d7f46ad164cb31d/Classes/DataCollectors/BaseCollector.php#L52-L59 | train |
Konafets/typo3_debugbar | Classes/DataCollectors/BaseCollector.php | BaseCollector.extGetFeAdminValue | public function extGetFeAdminValue($sectionName, $val = '')
{
$beUser = $this->getBackendUser();
// Override all settings with user TSconfig
if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
}
if (!$val && isset($beUser->extAdminConfig['override.'][$sectionName])) {
return $beUser->extAdminConfig['override.'][$sectionName];
}
$returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
// Exception for preview
return !$val ? true : $returnValue;
} | php | public function extGetFeAdminValue($sectionName, $val = '')
{
$beUser = $this->getBackendUser();
// Override all settings with user TSconfig
if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
}
if (!$val && isset($beUser->extAdminConfig['override.'][$sectionName])) {
return $beUser->extAdminConfig['override.'][$sectionName];
}
$returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
// Exception for preview
return !$val ? true : $returnValue;
} | [
"public",
"function",
"extGetFeAdminValue",
"(",
"$",
"sectionName",
",",
"$",
"val",
"=",
"''",
")",
"{",
"$",
"beUser",
"=",
"$",
"this",
"->",
"getBackendUser",
"(",
")",
";",
"// Override all settings with user TSconfig",
"if",
"(",
"$",
"val",
"&&",
"is... | Returns the value for an Admin Panel setting.
@param string $sectionName Module key
@param string $val Setting key
@return mixed The setting value | [
"Returns",
"the",
"value",
"for",
"an",
"Admin",
"Panel",
"setting",
"."
] | cc9b168d38994652c5b077617d7f46ad164cb31d | https://github.com/Konafets/typo3_debugbar/blob/cc9b168d38994652c5b077617d7f46ad164cb31d/Classes/DataCollectors/BaseCollector.php#L76-L92 | train |
Opifer/Cms | src/ContentBundle/Block/Service/CollectionBlockService.php | CollectionBlockService.loadCollection | protected function loadCollection(BlockInterface $block)
{
$properties = $block->getProperties();
$conditions = (isset($properties['conditions'])) ? $properties['conditions'] : '[]';
$conditions = $this->expressionEngine->deserialize($conditions);
if (empty($conditions)) {
return;
}
$site = $this->siteManager->getSite();
$qb = $this->expressionEngine->toQueryBuilder($conditions, $this->contentManager->getClass());
$qb->andWhere('a.publishAt < :now OR a.publishAt IS NULL')
->andWhere('a.active = :active')
->andWhere('a.layout = :layout');
if ($site == null) {
$qb->andWhere('a.site IS NULL');
} else {
$qb->andWhere('a.site = :site')
->setParameter('site', $site);
}
$qb->setParameter('active', true)
->setParameter('layout', false)
->setParameter('now', new \DateTime());
if (isset($properties['order_by'])) {
$direction = (isset($properties['order_direction'])) ? $properties['order_direction'] : 'ASC';
$qb->orderBy('a.'.$properties['order_by'], $direction);
}
$limit = (isset($properties['limit'])) ? $properties['limit'] : 10;
$qb->setMaxResults($limit);
$collection = $qb->getQuery()->getResult();
if ($collection) {
$block->setCollection($collection);
}
} | php | protected function loadCollection(BlockInterface $block)
{
$properties = $block->getProperties();
$conditions = (isset($properties['conditions'])) ? $properties['conditions'] : '[]';
$conditions = $this->expressionEngine->deserialize($conditions);
if (empty($conditions)) {
return;
}
$site = $this->siteManager->getSite();
$qb = $this->expressionEngine->toQueryBuilder($conditions, $this->contentManager->getClass());
$qb->andWhere('a.publishAt < :now OR a.publishAt IS NULL')
->andWhere('a.active = :active')
->andWhere('a.layout = :layout');
if ($site == null) {
$qb->andWhere('a.site IS NULL');
} else {
$qb->andWhere('a.site = :site')
->setParameter('site', $site);
}
$qb->setParameter('active', true)
->setParameter('layout', false)
->setParameter('now', new \DateTime());
if (isset($properties['order_by'])) {
$direction = (isset($properties['order_direction'])) ? $properties['order_direction'] : 'ASC';
$qb->orderBy('a.'.$properties['order_by'], $direction);
}
$limit = (isset($properties['limit'])) ? $properties['limit'] : 10;
$qb->setMaxResults($limit);
$collection = $qb->getQuery()->getResult();
if ($collection) {
$block->setCollection($collection);
}
} | [
"protected",
"function",
"loadCollection",
"(",
"BlockInterface",
"$",
"block",
")",
"{",
"$",
"properties",
"=",
"$",
"block",
"->",
"getProperties",
"(",
")",
";",
"$",
"conditions",
"=",
"(",
"isset",
"(",
"$",
"properties",
"[",
"'conditions'",
"]",
")... | Load the collection if any conditions are defined.
@param BlockInterface $block | [
"Load",
"the",
"collection",
"if",
"any",
"conditions",
"are",
"defined",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/Service/CollectionBlockService.php#L267-L310 | train |
Opifer/Cms | src/ContentBundle/Block/Service/PointerBlockService.php | PointerBlockService.setResponseHeaders | protected function setResponseHeaders(BlockInterface $block, Response $response)
{
if ($block && $block->getReference()) {
if ($this->getReferenceService($block)->isEsiEnabled($block->getReference())) {
$this->getReferenceService($block)->setResponseHeaders($block->getReference(), $response);
} else {
$response->setLastModified($block->getReference()->getUpdatedAt());
$response->setPublic();
}
}
} | php | protected function setResponseHeaders(BlockInterface $block, Response $response)
{
if ($block && $block->getReference()) {
if ($this->getReferenceService($block)->isEsiEnabled($block->getReference())) {
$this->getReferenceService($block)->setResponseHeaders($block->getReference(), $response);
} else {
$response->setLastModified($block->getReference()->getUpdatedAt());
$response->setPublic();
}
}
} | [
"protected",
"function",
"setResponseHeaders",
"(",
"BlockInterface",
"$",
"block",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"block",
"&&",
"$",
"block",
"->",
"getReference",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRefer... | Sets the response headers defined on the reference service
{@inheritdoc} | [
"Sets",
"the",
"response",
"headers",
"defined",
"on",
"the",
"reference",
"service"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/Service/PointerBlockService.php#L159-L169 | train |
Opifer/Cms | src/CmsBundle/Controller/Backend/PostController.php | PostController.listAction | public function listAction()
{
$source = new Entity($this->get('opifer.form.post_manager')->getClass());
$formColumn = new TextColumn(['id' => 'posts', 'title' => 'Form', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]);
$formColumn->manipulateRenderCell(function ($value, $row, $router) {
return '<a href="'.$this->generateUrl('opifer_form_form_edit', ['id'=> $row->getEntity()->getForm()->getId()]).'">'.$row->getEntity()->getForm()->getName().'</a>';
});
$viewAction = new RowAction('view', 'opifer_form_post_view');
$viewAction->setRouteParameters(['id']);
$deleteAction = new RowAction('delete', 'opifer_form_post_delete');
$deleteAction->setRouteParameters(['id']);
$grid = $this->get('grid');
$grid->setId('posts')
->setSource($source)
->setDefaultOrder('id', 'desc')
->addColumn($formColumn, 2)
->addRowAction($viewAction)
->addRowAction($deleteAction);
return $grid->getGridResponse('OpiferCmsBundle:Backend/Post:list.html.twig');
} | php | public function listAction()
{
$source = new Entity($this->get('opifer.form.post_manager')->getClass());
$formColumn = new TextColumn(['id' => 'posts', 'title' => 'Form', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]);
$formColumn->manipulateRenderCell(function ($value, $row, $router) {
return '<a href="'.$this->generateUrl('opifer_form_form_edit', ['id'=> $row->getEntity()->getForm()->getId()]).'">'.$row->getEntity()->getForm()->getName().'</a>';
});
$viewAction = new RowAction('view', 'opifer_form_post_view');
$viewAction->setRouteParameters(['id']);
$deleteAction = new RowAction('delete', 'opifer_form_post_delete');
$deleteAction->setRouteParameters(['id']);
$grid = $this->get('grid');
$grid->setId('posts')
->setSource($source)
->setDefaultOrder('id', 'desc')
->addColumn($formColumn, 2)
->addRowAction($viewAction)
->addRowAction($deleteAction);
return $grid->getGridResponse('OpiferCmsBundle:Backend/Post:list.html.twig');
} | [
"public",
"function",
"listAction",
"(",
")",
"{",
"$",
"source",
"=",
"new",
"Entity",
"(",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.post_manager'",
")",
"->",
"getClass",
"(",
")",
")",
";",
"$",
"formColumn",
"=",
"new",
"TextColumn",
"(",
"[",
... | Lists all posts from every form
@return Response | [
"Lists",
"all",
"posts",
"from",
"every",
"form"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/PostController.php#L64-L88 | train |
joomlatools/joomla-basicauth | basicauth.php | plgSystemBasicAuth.onAfterRoute | public function onAfterRoute()
{
$app = JFactory::getApplication();
$username = $app->input->server->get('PHP_AUTH_USER', null, 'string');
$password = $app->input->server->get('PHP_AUTH_PW', null, 'string');
if ($username && $password)
{
if (!$this->_login($username, $password, $app)) {
throw new Exception('Login failed', 401);
}
}
} | php | public function onAfterRoute()
{
$app = JFactory::getApplication();
$username = $app->input->server->get('PHP_AUTH_USER', null, 'string');
$password = $app->input->server->get('PHP_AUTH_PW', null, 'string');
if ($username && $password)
{
if (!$this->_login($username, $password, $app)) {
throw new Exception('Login failed', 401);
}
}
} | [
"public",
"function",
"onAfterRoute",
"(",
")",
"{",
"$",
"app",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
";",
"$",
"username",
"=",
"$",
"app",
"->",
"input",
"->",
"server",
"->",
"get",
"(",
"'PHP_AUTH_USER'",
",",
"null",
",",
"'string'",
... | Ask for authentication and log the user in into the application.
@return void | [
"Ask",
"for",
"authentication",
"and",
"log",
"the",
"user",
"in",
"into",
"the",
"application",
"."
] | 5c4cfef0bad5949158d9f04d02e6d65615ea65d9 | https://github.com/joomlatools/joomla-basicauth/blob/5c4cfef0bad5949158d9f04d02e6d65615ea65d9/basicauth.php#L58-L71 | train |
joomlatools/joomla-basicauth | basicauth.php | plgSystemBasicAuth._login | protected function _login($username, $password, $application)
{
// If we did receive the user credentials from the user, try to login
if($application->login(array('username' => $username, 'password' => $password)) !== true) {
return false;
}
// If we have logged in succesfully, make sure to fullfil
// Koowa's CSRF authenticator checks if the framework is loaded.
if (class_exists('Koowa'))
{
$manager = KObjectManager::getInstance();
$request = $manager->getInstance()->getObject('com:koowa.dispatcher.request');
$user = $manager->getInstance()->getObject('user');
$token = $user->getSession()->getToken();
$request->setReferrer(JUri::root());
$request->getHeaders()->add(array('X-Xsrf-Token' => $token));
$request->getCookies()->add(array('csrf_token' => $token));
}
return true;
} | php | protected function _login($username, $password, $application)
{
// If we did receive the user credentials from the user, try to login
if($application->login(array('username' => $username, 'password' => $password)) !== true) {
return false;
}
// If we have logged in succesfully, make sure to fullfil
// Koowa's CSRF authenticator checks if the framework is loaded.
if (class_exists('Koowa'))
{
$manager = KObjectManager::getInstance();
$request = $manager->getInstance()->getObject('com:koowa.dispatcher.request');
$user = $manager->getInstance()->getObject('user');
$token = $user->getSession()->getToken();
$request->setReferrer(JUri::root());
$request->getHeaders()->add(array('X-Xsrf-Token' => $token));
$request->getCookies()->add(array('csrf_token' => $token));
}
return true;
} | [
"protected",
"function",
"_login",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"application",
")",
"{",
"// If we did receive the user credentials from the user, try to login",
"if",
"(",
"$",
"application",
"->",
"login",
"(",
"array",
"(",
"'username'",
... | Logs in a given user to an application.
@param string $username The username.
@param string $password The password.
@param object $application The application.
@return bool True if login was successful, false otherwise. | [
"Logs",
"in",
"a",
"given",
"user",
"to",
"an",
"application",
"."
] | 5c4cfef0bad5949158d9f04d02e6d65615ea65d9 | https://github.com/joomlatools/joomla-basicauth/blob/5c4cfef0bad5949158d9f04d02e6d65615ea65d9/basicauth.php#L82-L105 | train |
Opifer/Cms | src/MediaBundle/Model/Media.php | Media.getReadableFilesize | public function getReadableFilesize()
{
$size = $this->filesize;
if ($size < 1) {
return $size;
}
if ($size < 1024) {
return $size.'b';
} else {
$help = $size / 1024;
if ($help < 1024) {
return round($help, 1).'kb';
} else {
return round(($help / 1024), 1).'mb';
}
}
} | php | public function getReadableFilesize()
{
$size = $this->filesize;
if ($size < 1) {
return $size;
}
if ($size < 1024) {
return $size.'b';
} else {
$help = $size / 1024;
if ($help < 1024) {
return round($help, 1).'kb';
} else {
return round(($help / 1024), 1).'mb';
}
}
} | [
"public",
"function",
"getReadableFilesize",
"(",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"filesize",
";",
"if",
"(",
"$",
"size",
"<",
"1",
")",
"{",
"return",
"$",
"size",
";",
"}",
"if",
"(",
"$",
"size",
"<",
"1024",
")",
"{",
"return"... | Get filesize with filesize extension.
@JMS\VirtualProperty
@JMS\SerializedName("readable_filesize")
@return int|string | [
"Get",
"filesize",
"with",
"filesize",
"extension",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Model/Media.php#L465-L482 | train |
Opifer/Cms | src/MediaBundle/Model/MediaRepository.php | MediaRepository.createQueryBuilderFromRequest | public function createQueryBuilderFromRequest(Request $request)
{
$qb = $this->createQueryBuilder('m');
if ($request->get('ids')) {
$ids = explode(',', $request->get('ids'));
$qb->andWhere('m.id IN (:ids)')->setParameter('ids', $ids);
}
$qb->andWhere('m.status = :status')->setParameter('status', Media::STATUS_ENABLED);
if ($request->get('search')) {
$qb->andWhere('m.name LIKE :term')->setParameter('term', '%'.$request->get('search').'%');
}
if ($request->get('order')) {
$direction = ($request->get('orderdir')) ? $request->get('orderdir') : 'asc';
$qb->orderBy('m.'.$request->get('order'), $direction);
}
return $qb;
} | php | public function createQueryBuilderFromRequest(Request $request)
{
$qb = $this->createQueryBuilder('m');
if ($request->get('ids')) {
$ids = explode(',', $request->get('ids'));
$qb->andWhere('m.id IN (:ids)')->setParameter('ids', $ids);
}
$qb->andWhere('m.status = :status')->setParameter('status', Media::STATUS_ENABLED);
if ($request->get('search')) {
$qb->andWhere('m.name LIKE :term')->setParameter('term', '%'.$request->get('search').'%');
}
if ($request->get('order')) {
$direction = ($request->get('orderdir')) ? $request->get('orderdir') : 'asc';
$qb->orderBy('m.'.$request->get('order'), $direction);
}
return $qb;
} | [
"public",
"function",
"createQueryBuilderFromRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"if",
"(",
"$",
"request",
"->",
"get",
"(",
"'ids'",
")",
")",
"{",
"$",
"i... | Create the query builder from request.
@param Request $request
@return QueryBuilder | [
"Create",
"the",
"query",
"builder",
"from",
"request",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Model/MediaRepository.php#L18-L40 | train |
Opifer/Cms | src/MediaBundle/Model/MediaRepository.php | MediaRepository.search | public function search($term, $limit, $offset, $orderBy = null)
{
$qb = $this->createQueryBuilder('m');
$qb->where('m.name LIKE :term')
->andWhere('m.status IN (:statuses)')
->setParameters(array(
'term' => '%'.$term.'%',
'statuses' => array(0, 1),
)
);
if ($limit) {
$qb->setMaxResults($limit);
}
if ($offset) {
$qb->setFirstResult($offset);
}
return $qb->getQuery()->getResult();
} | php | public function search($term, $limit, $offset, $orderBy = null)
{
$qb = $this->createQueryBuilder('m');
$qb->where('m.name LIKE :term')
->andWhere('m.status IN (:statuses)')
->setParameters(array(
'term' => '%'.$term.'%',
'statuses' => array(0, 1),
)
);
if ($limit) {
$qb->setMaxResults($limit);
}
if ($offset) {
$qb->setFirstResult($offset);
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"search",
"(",
"$",
"term",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"orderBy",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'m... | Search media items by a searchterm.
@param string $term
@param int $limit
@param int $offset
@param array $orderBy
@return array | [
"Search",
"media",
"items",
"by",
"a",
"searchterm",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Model/MediaRepository.php#L52-L73 | train |
heroicpixels/filterable | src/Heroicpixels/Filterable/FilterableTrait.php | FilterableTrait.setQuerystring | public function setQuerystring(array $str = array(), $append = true, $default = true)
{
if ( is_null($this->filterable) ) {
$this->resetFilterableOptions();
}
if ( sizeof($str) == 0 && $default ) {
// Default to PHP query string
parse_str($_SERVER['QUERY_STRING'], $this->filterable['qstring']);
} else {
$this->filterable['qstring'] = $str;
}
if ( sizeof($this->filterable['qstring']) > 0 ) {
if ( !$append ) {
// Overwrite data
$this->filterable['filters'] = array();
}
foreach ( $this->filterable['qstring'] as $k => $v ) {
if ( $v == '' ) {
continue;
}
$thisColumn = isset($this->filterable['columns'][$k]) ? $this->filterable['columns'][$k] : false;
if ( $thisColumn ) {
// Query string part matches column (or alias)
$this->filterable['filters'][$thisColumn]['val'] = $v;
// Evaluate boolean parameter in query string
$thisBoolData = isset($this->filterable['qstring']['bool'][$k]) ? $this->filterable['qstring']['bool'][$k] : false;
$thisBoolAvailable = $thisBoolData && isset($this->filterable['bools'][$thisBoolData]) ? $this->filterable['bools'][$thisBoolData] : false;
if ( $thisBoolData && $thisBoolAvailable ) {
$this->filterable['filters'][$thisColumn]['boolean'] = $thisBoolAvailable;
} else {
$this->filterable['filters'][$thisColumn]['boolean'] = $this->filterable['defaultWhere'];
}
// Evaluate operator parameters in the query string
if ( isset($this->filterable['qstring']['operator'][$k]) && in_array($this->filterable['qstring']['operator'][$k], $this->filterable['operators']) ) {
$this->filterable['filters'][$thisColumn]['operator'] = $this->filterable['qstring']['operator'][$k];
} else {
// Default operator
$this->filterable['filters'][$thisColumn]['operator'] = $this->filterable['defaultOperator'];
}
}
}
}
return $this;
} | php | public function setQuerystring(array $str = array(), $append = true, $default = true)
{
if ( is_null($this->filterable) ) {
$this->resetFilterableOptions();
}
if ( sizeof($str) == 0 && $default ) {
// Default to PHP query string
parse_str($_SERVER['QUERY_STRING'], $this->filterable['qstring']);
} else {
$this->filterable['qstring'] = $str;
}
if ( sizeof($this->filterable['qstring']) > 0 ) {
if ( !$append ) {
// Overwrite data
$this->filterable['filters'] = array();
}
foreach ( $this->filterable['qstring'] as $k => $v ) {
if ( $v == '' ) {
continue;
}
$thisColumn = isset($this->filterable['columns'][$k]) ? $this->filterable['columns'][$k] : false;
if ( $thisColumn ) {
// Query string part matches column (or alias)
$this->filterable['filters'][$thisColumn]['val'] = $v;
// Evaluate boolean parameter in query string
$thisBoolData = isset($this->filterable['qstring']['bool'][$k]) ? $this->filterable['qstring']['bool'][$k] : false;
$thisBoolAvailable = $thisBoolData && isset($this->filterable['bools'][$thisBoolData]) ? $this->filterable['bools'][$thisBoolData] : false;
if ( $thisBoolData && $thisBoolAvailable ) {
$this->filterable['filters'][$thisColumn]['boolean'] = $thisBoolAvailable;
} else {
$this->filterable['filters'][$thisColumn]['boolean'] = $this->filterable['defaultWhere'];
}
// Evaluate operator parameters in the query string
if ( isset($this->filterable['qstring']['operator'][$k]) && in_array($this->filterable['qstring']['operator'][$k], $this->filterable['operators']) ) {
$this->filterable['filters'][$thisColumn]['operator'] = $this->filterable['qstring']['operator'][$k];
} else {
// Default operator
$this->filterable['filters'][$thisColumn]['operator'] = $this->filterable['defaultOperator'];
}
}
}
}
return $this;
} | [
"public",
"function",
"setQuerystring",
"(",
"array",
"$",
"str",
"=",
"array",
"(",
")",
",",
"$",
"append",
"=",
"true",
",",
"$",
"default",
"=",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"filterable",
")",
")",
"{",
"$",
... | Parse the query string
@param $str array The query string
@param $append Append or overwrite existing query string data
@param $default Default to $_SERVER['QUERY_STRING'] if $str isn't given
@return $this | [
"Parse",
"the",
"query",
"string"
] | 04d6bdeaf5fbc77e19d666cb06739a4af85d3d4f | https://github.com/heroicpixels/filterable/blob/04d6bdeaf5fbc77e19d666cb06739a4af85d3d4f/src/Heroicpixels/Filterable/FilterableTrait.php#L80-L123 | train |
heroicpixels/filterable | src/Heroicpixels/Filterable/FilterableTrait.php | FilterableTrait.scopeFilterColumns | public function scopeFilterColumns($query, $columns = array(), $validate = false)
{
if ( sizeof($columns) > 0 ) {
// Set columns that can be filtered
$this->setColumns($columns);
}
// Validate columns
if ( $validate ) {
$this->validateColumns();
}
// Ensure that query string is parsed at least once
if ( sizeof($this->filterable['filters']) == 0 ) {
$this->setQuerystring();
}
// Apply conditions to Eloquent query object
if ( sizeof($this->filterable['filters']) > 0 ) {
foreach ( $this->filterable['filters'] as $k => $v ) {
$where = $v['boolean'];
if ( is_array($v['val']) ) {
if ( isset($v['val']['start']) && isset($v['val']['end']) ) {
// BETWEEN a AND b
$query->whereBetween($k, array($v['val']['start'], $v['val']['end']));
} else {
// a = b OR c = d OR...
$query->{$where}(function($q) use ($k, $v, $query)
{
foreach ( $v['val'] as $key => $val ) {
$q->orWhere($k, $v['operator'], $val);
}
});
}
} else {
// a = b
$query->{$where}($k, $v['operator'], $v['val']);
}
}
}
// Apply callbacks
if ( sizeof($this->filterable['callbacks']) > 0 ) {
foreach ( $this->filterable['callbacks'] as $v ) {
$v($query);
}
}
// Sorting
if ( isset($this->filterable['qstring'][$this->filterable['orderby']]) && isset($this->filterable['columns'][$this->filterable['qstring'][$this->filterable['orderby']]]) ) {
$order = isset($this->filterable['qstring'][$this->filterable['order']]) ? $this->filterable['qstring'][$this->filterable['order']] : 'asc';
$query->orderBy($this->filterable['columns'][$this->filterable['qstring'][$this->filterable['orderby']]], $order);
}
return $query;
} | php | public function scopeFilterColumns($query, $columns = array(), $validate = false)
{
if ( sizeof($columns) > 0 ) {
// Set columns that can be filtered
$this->setColumns($columns);
}
// Validate columns
if ( $validate ) {
$this->validateColumns();
}
// Ensure that query string is parsed at least once
if ( sizeof($this->filterable['filters']) == 0 ) {
$this->setQuerystring();
}
// Apply conditions to Eloquent query object
if ( sizeof($this->filterable['filters']) > 0 ) {
foreach ( $this->filterable['filters'] as $k => $v ) {
$where = $v['boolean'];
if ( is_array($v['val']) ) {
if ( isset($v['val']['start']) && isset($v['val']['end']) ) {
// BETWEEN a AND b
$query->whereBetween($k, array($v['val']['start'], $v['val']['end']));
} else {
// a = b OR c = d OR...
$query->{$where}(function($q) use ($k, $v, $query)
{
foreach ( $v['val'] as $key => $val ) {
$q->orWhere($k, $v['operator'], $val);
}
});
}
} else {
// a = b
$query->{$where}($k, $v['operator'], $v['val']);
}
}
}
// Apply callbacks
if ( sizeof($this->filterable['callbacks']) > 0 ) {
foreach ( $this->filterable['callbacks'] as $v ) {
$v($query);
}
}
// Sorting
if ( isset($this->filterable['qstring'][$this->filterable['orderby']]) && isset($this->filterable['columns'][$this->filterable['qstring'][$this->filterable['orderby']]]) ) {
$order = isset($this->filterable['qstring'][$this->filterable['order']]) ? $this->filterable['qstring'][$this->filterable['order']] : 'asc';
$query->orderBy($this->filterable['columns'][$this->filterable['qstring'][$this->filterable['orderby']]], $order);
}
return $query;
} | [
"public",
"function",
"scopeFilterColumns",
"(",
"$",
"query",
",",
"$",
"columns",
"=",
"array",
"(",
")",
",",
"$",
"validate",
"=",
"false",
")",
"{",
"if",
"(",
"sizeof",
"(",
"$",
"columns",
")",
">",
"0",
")",
"{",
"// Set columns that can be filte... | Laravel Eloquent query scope.
@param $query Eloquent query object
@return Eloquent query object | [
"Laravel",
"Eloquent",
"query",
"scope",
"."
] | 04d6bdeaf5fbc77e19d666cb06739a4af85d3d4f | https://github.com/heroicpixels/filterable/blob/04d6bdeaf5fbc77e19d666cb06739a4af85d3d4f/src/Heroicpixels/Filterable/FilterableTrait.php#L130-L179 | train |
Opifer/Cms | src/ContentBundle/Environment/Environment.php | Environment.getAllBlocks | public function getAllBlocks()
{
$this->load();
$blocks = [];
foreach ($this->blockCache as $blockCache) {
$blocks = array_merge($blocks, $blockCache);
}
return $blocks;
} | php | public function getAllBlocks()
{
$this->load();
$blocks = [];
foreach ($this->blockCache as $blockCache) {
$blocks = array_merge($blocks, $blockCache);
}
return $blocks;
} | [
"public",
"function",
"getAllBlocks",
"(",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"$",
"blocks",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"blockCache",
"as",
"$",
"blockCache",
")",
"{",
"$",
"blocks",
"=",
"array_merge",
... | Get all cached blocks
Note; this is a dangerous method and should only be used to retrieve
blocks from caches other than the current `object`.
@return array | [
"Get",
"all",
"cached",
"blocks"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Environment/Environment.php#L155-L165 | train |
aegis-security/JWT | src/Signature.php | Signature.verify | public function verify(Signer $signer, $payload, $key)
{
return $signer->verify($this->hash, $payload, $key);
} | php | public function verify(Signer $signer, $payload, $key)
{
return $signer->verify($this->hash, $payload, $key);
} | [
"public",
"function",
"verify",
"(",
"Signer",
"$",
"signer",
",",
"$",
"payload",
",",
"$",
"key",
")",
"{",
"return",
"$",
"signer",
"->",
"verify",
"(",
"$",
"this",
"->",
"hash",
",",
"$",
"payload",
",",
"$",
"key",
")",
";",
"}"
] | Verifies if the current hash matches with with the result of the creation of
a new signature with given data
@param Signer $signer
@param string $payload
@param string $key
@return boolean | [
"Verifies",
"if",
"the",
"current",
"hash",
"matches",
"with",
"with",
"the",
"result",
"of",
"the",
"creation",
"of",
"a",
"new",
"signature",
"with",
"given",
"data"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signature.php#L42-L45 | train |
Opifer/Cms | src/MediaBundle/Provider/FileProvider.php | FileProvider.buildCreateForm | public function buildCreateForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('files', DropzoneType::class, [
'mapped' => false,
'path' => $this->router->generate('opifer_api_media_upload'),
'form_action' => $this->router->generate('opifer_media_media_updateall'),
'label' => '',
])
;
} | php | public function buildCreateForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('files', DropzoneType::class, [
'mapped' => false,
'path' => $this->router->generate('opifer_api_media_upload'),
'form_action' => $this->router->generate('opifer_media_media_updateall'),
'label' => '',
])
;
} | [
"public",
"function",
"buildCreateForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'files'",
",",
"DropzoneType",
"::",
"class",
",",
"[",
"'mapped'",
"=>",
"false",
",",
"'path'",... | Build the add file form.
@param FormBuilderInterface $builder
@param array $options | [
"Build",
"the",
"add",
"file",
"form",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Provider/FileProvider.php#L56-L66 | train |
Opifer/Cms | src/MailingListBundle/Repository/MailingListRepository.php | MailingListRepository.findByIds | public function findByIds($ids)
{
if (!is_array($ids)) {
$ids = explode(',', $ids);
}
return $this->createQueryBuilder('ml')
->andWhere('ml.id IN (:ids)')
->setParameter('ids', $ids)
->getQuery()
->getResult();
} | php | public function findByIds($ids)
{
if (!is_array($ids)) {
$ids = explode(',', $ids);
}
return $this->createQueryBuilder('ml')
->andWhere('ml.id IN (:ids)')
->setParameter('ids', $ids)
->getQuery()
->getResult();
} | [
"public",
"function",
"findByIds",
"(",
"$",
"ids",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"ids",
"=",
"explode",
"(",
"','",
",",
"$",
"ids",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"... | Find the mailinglist by an array of IDs
@param array|string $ids
@return MailingList[] | [
"Find",
"the",
"mailinglist",
"by",
"an",
"array",
"of",
"IDs"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Repository/MailingListRepository.php#L30-L41 | train |
Opifer/Cms | src/ContentBundle/EventListener/BlockDiscriminatorListener.php | BlockDiscriminatorListener.getDiscriminatorMap | public function getDiscriminatorMap()
{
$map = array();
foreach ($this->blockManager->getValues() as $alias => $value) {
$map[$alias] = $value->getEntity();
}
return $map;
} | php | public function getDiscriminatorMap()
{
$map = array();
foreach ($this->blockManager->getValues() as $alias => $value) {
$map[$alias] = $value->getEntity();
}
return $map;
} | [
"public",
"function",
"getDiscriminatorMap",
"(",
")",
"{",
"$",
"map",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"blockManager",
"->",
"getValues",
"(",
")",
"as",
"$",
"alias",
"=>",
"$",
"value",
")",
"{",
"$",
"map",
"[",
... | Transforms the registered blocks into a discriminatorMap
@return array | [
"Transforms",
"the",
"registered",
"blocks",
"into",
"a",
"discriminatorMap"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/EventListener/BlockDiscriminatorListener.php#L47-L55 | train |
Opifer/Cms | src/MediaBundle/Validator/ValidJsonValidator.php | ValidJsonValidator.validate | public function validate($value, Constraint $constraint)
{
if (is_array($value)) {
$value = json_encode($value);
}
if (!json_decode($value, true)) {
$this->context->addViolation(
$constraint->message,
array()
);
}
} | php | public function validate($value, Constraint $constraint)
{
if (is_array($value)) {
$value = json_encode($value);
}
if (!json_decode($value, true)) {
$this->context->addViolation(
$constraint->message,
array()
);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"!",
"json_... | Checks if the passed value is a valid JSON string.
If it's already converted by, for example, Doctrine's json_array type,
encode the value first and then check if the encode value is valid.
@param string|array $value
@param Constraint $constraint | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"a",
"valid",
"JSON",
"string",
".",
"If",
"it",
"s",
"already",
"converted",
"by",
"for",
"example",
"Doctrine",
"s",
"json_array",
"type",
"encode",
"the",
"value",
"first",
"and",
"then",
"check",
"if",
... | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Validator/ValidJsonValidator.php#L18-L30 | train |
Opifer/Cms | src/CmsBundle/Manager/ContentManager.php | ContentManager.createMissingValueSet | public function createMissingValueSet(Content $content)
{
if ($content->getContentType() !== null && $content->getValueSet() === null)
{
$valueSet = new ValueSet();
$this->em->persist($valueSet);
$valueSet->setSchema($content->getContentType()->getSchema());
$content->setValueSet($valueSet);
$content = $this->save($content);
}
return $content;
} | php | public function createMissingValueSet(Content $content)
{
if ($content->getContentType() !== null && $content->getValueSet() === null)
{
$valueSet = new ValueSet();
$this->em->persist($valueSet);
$valueSet->setSchema($content->getContentType()->getSchema());
$content->setValueSet($valueSet);
$content = $this->save($content);
}
return $content;
} | [
"public",
"function",
"createMissingValueSet",
"(",
"Content",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"->",
"getContentType",
"(",
")",
"!==",
"null",
"&&",
"$",
"content",
"->",
"getValueSet",
"(",
")",
"===",
"null",
")",
"{",
"$",
"value... | Creates a ValueSet entity for Content when missing and there is a ContentType set.
@param Content $content
@return Content | [
"Creates",
"a",
"ValueSet",
"entity",
"for",
"Content",
"when",
"missing",
"and",
"there",
"is",
"a",
"ContentType",
"set",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Manager/ContentManager.php#L47-L61 | train |
Opifer/Cms | src/ContentBundle/Form/Type/ContentTreePickerType.php | ContentTreePickerType.stripMetadata | protected function stripMetadata(array $array, $stripped = [])
{
$allowed = ['id', '__children'];
foreach ($array as $item) {
if (count($item['__children'])) {
$item['__children'] = $this->stripMetadata($item['__children'], $stripped);
}
$stripped[] = array_intersect_key($item, array_flip($allowed));
}
return $stripped;
} | php | protected function stripMetadata(array $array, $stripped = [])
{
$allowed = ['id', '__children'];
foreach ($array as $item) {
if (count($item['__children'])) {
$item['__children'] = $this->stripMetadata($item['__children'], $stripped);
}
$stripped[] = array_intersect_key($item, array_flip($allowed));
}
return $stripped;
} | [
"protected",
"function",
"stripMetadata",
"(",
"array",
"$",
"array",
",",
"$",
"stripped",
"=",
"[",
"]",
")",
"{",
"$",
"allowed",
"=",
"[",
"'id'",
",",
"'__children'",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"item",
")",
"{",
"if",
"... | Strips metadata that should not be stored
@param array $array
@param array $stripped
@return array | [
"Strips",
"metadata",
"that",
"should",
"not",
"be",
"stored"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Form/Type/ContentTreePickerType.php#L65-L77 | train |
Konafets/typo3_debugbar | Classes/Typo3DebugBar.php | Typo3DebugBar.var_dump | public function var_dump($item)
{
if ($this->hasCollector('vardump')) {
/** @var VarDumpCollector $collector */
$collector = $this->getCollector('vardump');
$collector->addVarDump($item);
}
} | php | public function var_dump($item)
{
if ($this->hasCollector('vardump')) {
/** @var VarDumpCollector $collector */
$collector = $this->getCollector('vardump');
$collector->addVarDump($item);
}
} | [
"public",
"function",
"var_dump",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasCollector",
"(",
"'vardump'",
")",
")",
"{",
"/** @var VarDumpCollector $collector */",
"$",
"collector",
"=",
"$",
"this",
"->",
"getCollector",
"(",
"'vardump'",
... | Adds an item to the VarDumpCollector
@param mixed $item
@throws DebugBarException | [
"Adds",
"an",
"item",
"to",
"the",
"VarDumpCollector"
] | cc9b168d38994652c5b077617d7f46ad164cb31d | https://github.com/Konafets/typo3_debugbar/blob/cc9b168d38994652c5b077617d7f46ad164cb31d/Classes/Typo3DebugBar.php#L389-L396 | train |
Opifer/Cms | src/EavBundle/Form/EventListener/ValuesSubscriber.php | ValuesSubscriber.preSetData | public function preSetData(FormEvent $event)
{
$data = $event->getData();
$form = $event->getForm();
$fields = $form->getConfig()->getOption('fields');
if (null === $data || '' === $data) {
$data = [];
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
}
// Sorting values so that they display in sorted order of the attributes
uasort($data, function ($a, $b) {
return $a->getAttribute()->getSort() > $b->getAttribute()->getSort();
});
/**
* @var string $name
* @var Value $value
*/
foreach ($data as $name => $value) {
//Do not add fields when there not in fields value when giving.
if (!empty($fields) && !in_array($name, $fields)) {
continue;
}
// Do not add fields dynamically if they've already been set statically.
// This allows us to override the formtypes from inside the form type
// that's calling this subscriber.
if ($form->has($name)) {
continue;
}
$form->add($name, ValueType::class, [
'label' => $value->getAttribute()->getDisplayName(),
'required' => $value->getAttribute()->getRequired(),
'attribute' => $value->getAttribute(),
'entity' => get_class($value),
'value' => $value,
'attr' => ['help_text' => $value->getAttribute()->getDescription()]
]);
}
} | php | public function preSetData(FormEvent $event)
{
$data = $event->getData();
$form = $event->getForm();
$fields = $form->getConfig()->getOption('fields');
if (null === $data || '' === $data) {
$data = [];
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
}
// Sorting values so that they display in sorted order of the attributes
uasort($data, function ($a, $b) {
return $a->getAttribute()->getSort() > $b->getAttribute()->getSort();
});
/**
* @var string $name
* @var Value $value
*/
foreach ($data as $name => $value) {
//Do not add fields when there not in fields value when giving.
if (!empty($fields) && !in_array($name, $fields)) {
continue;
}
// Do not add fields dynamically if they've already been set statically.
// This allows us to override the formtypes from inside the form type
// that's calling this subscriber.
if ($form->has($name)) {
continue;
}
$form->add($name, ValueType::class, [
'label' => $value->getAttribute()->getDisplayName(),
'required' => $value->getAttribute()->getRequired(),
'attribute' => $value->getAttribute(),
'entity' => get_class($value),
'value' => $value,
'attr' => ['help_text' => $value->getAttribute()->getDescription()]
]);
}
} | [
"public",
"function",
"preSetData",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"$",
"data",
"=",
"$",
"event",
"->",
"getData",
"(",
")",
";",
"$",
"form",
"=",
"$",
"event",
"->",
"getForm",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"form",
"->",
"... | Listens to the PRE_SET_DATA event and adds form fields dynamically.
@param FormEvent $event
@return void | [
"Listens",
"to",
"the",
"PRE_SET_DATA",
"event",
"and",
"adds",
"form",
"fields",
"dynamically",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Form/EventListener/ValuesSubscriber.php#L36-L79 | train |
recca0120/payum-ecpay | src/Api.php | Api.verifyHash | public function verifyHash(array $params)
{
$result = false;
try {
$this->sdk->CheckOutFeedback($params);
$result = true;
} catch (Exception $e) {
}
return $result;
} | php | public function verifyHash(array $params)
{
$result = false;
try {
$this->sdk->CheckOutFeedback($params);
$result = true;
} catch (Exception $e) {
}
return $result;
} | [
"public",
"function",
"verifyHash",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"$",
"this",
"->",
"sdk",
"->",
"CheckOutFeedback",
"(",
"$",
"params",
")",
";",
"$",
"result",
"=",
"true",
";",
"}",
"catch",
... | Verify if the hash of the given parameter is correct.
@param array $params
@return bool | [
"Verify",
"if",
"the",
"hash",
"of",
"the",
"given",
"parameter",
"is",
"correct",
"."
] | eecbac5196e1e4aa8af8234ed97c2d7a5ff36fe2 | https://github.com/recca0120/payum-ecpay/blob/eecbac5196e1e4aa8af8234ed97c2d7a5ff36fe2/src/Api.php#L23-L33 | train |
Opifer/Cms | src/RedirectBundle/Controller/RedirectController.php | RedirectController.editAction | public function editAction(Request $request, $id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$form = $this->createForm(RedirectType::class, $redirect);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$manager->save($redirect);
$this->addFlash('success', $this->get('translator')->trans('opifer_redirect.flash.updated'));
return $this->redirectToRoute('opifer_redirect_redirect_edit', ['id' => $redirect->getId()]);
}
return $this->render($this->container->getParameter('opifer_redirect.redirect_edit_view'), [
'form' => $form->createView(),
'redirect' => $redirect
]);
} | php | public function editAction(Request $request, $id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$form = $this->createForm(RedirectType::class, $redirect);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$manager->save($redirect);
$this->addFlash('success', $this->get('translator')->trans('opifer_redirect.flash.updated'));
return $this->redirectToRoute('opifer_redirect_redirect_edit', ['id' => $redirect->getId()]);
}
return $this->render($this->container->getParameter('opifer_redirect.redirect_edit_view'), [
'form' => $form->createView(),
'redirect' => $redirect
]);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.redirect.redirect_manager'",
")",
";",
"$",
"redirect",
"=",
"$",
"manager",
"->",
"getRepository",
"... | Edit a redirect
@param Request $request
@param int $id
@return RedirectResponse|Response | [
"Edit",
"a",
"redirect"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/RedirectBundle/Controller/RedirectController.php#L68-L88 | train |
Opifer/Cms | src/RedirectBundle/Controller/RedirectController.php | RedirectController.deleteAction | public function deleteAction($id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$manager->remove($redirect);
$this->addFlash('success', $this->get('translator')->trans('opifer_redirect.flash.deleted'));
return $this->redirectToRoute('opifer_redirect_redirect_index');
} | php | public function deleteAction($id)
{
$manager = $this->get('opifer.redirect.redirect_manager');
$redirect = $manager->getRepository()->find($id);
$manager->remove($redirect);
$this->addFlash('success', $this->get('translator')->trans('opifer_redirect.flash.deleted'));
return $this->redirectToRoute('opifer_redirect_redirect_index');
} | [
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.redirect.redirect_manager'",
")",
";",
"$",
"redirect",
"=",
"$",
"manager",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
... | Delete a redirect
@param int $id
@return RedirectResponse | [
"Delete",
"a",
"redirect"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/RedirectBundle/Controller/RedirectController.php#L97-L107 | train |
Opifer/Cms | src/ContentBundle/Model/ContentManager.php | ContentManager.getContentByReference | public function getContentByReference($reference)
{
if (is_numeric($reference)) {
// If the reference is numeric, it must be the content ID from an existing
// content item, which has to be updated.
$nestedContent = $this->getRepository()->find($reference);
} else {
// If not, $reference is a template name for a to-be-created content item.
$template = $this->em->getRepository($this->templateClass)->findOneByName($reference);
$nestedContent = $this->eavManager->initializeEntity($template);
$nestedContent->setNestedDefaults();
}
return $nestedContent;
} | php | public function getContentByReference($reference)
{
if (is_numeric($reference)) {
// If the reference is numeric, it must be the content ID from an existing
// content item, which has to be updated.
$nestedContent = $this->getRepository()->find($reference);
} else {
// If not, $reference is a template name for a to-be-created content item.
$template = $this->em->getRepository($this->templateClass)->findOneByName($reference);
$nestedContent = $this->eavManager->initializeEntity($template);
$nestedContent->setNestedDefaults();
}
return $nestedContent;
} | [
"public",
"function",
"getContentByReference",
"(",
"$",
"reference",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"reference",
")",
")",
"{",
"// If the reference is numeric, it must be the content ID from an existing",
"// content item, which has to be updated.",
"$",
"nest... | Get the content by a reference
If the passed reference is a numeric, it must be the content ID from a
to-be-updated content item.
If not, the reference must be the template name for a to-be-created
content item.
@param int|string $reference
@return ContentInterface | [
"Get",
"the",
"content",
"by",
"a",
"reference"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentManager.php#L108-L123 | train |
Opifer/Cms | src/ContentBundle/Model/ContentManager.php | ContentManager.detachAndPersist | private function detachAndPersist($entity)
{
$this->em->detach($entity);
$this->em->persist($entity);
} | php | private function detachAndPersist($entity)
{
$this->em->detach($entity);
$this->em->persist($entity);
} | [
"private",
"function",
"detachAndPersist",
"(",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"detach",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"}"
] | For cloning purpose
@param ContentInterface|\Opifer\EavBundle\Model\ValueSetInterface|\Opifer\EavBundle\Entity\Value $entity | [
"For",
"cloning",
"purpose"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentManager.php#L250-L254 | train |
Opifer/Cms | src/ContentBundle/Handler/RelativeSlugHandler.php | RelativeSlugHandler.hasChangedParent | private function hasChangedParent(SluggableAdapter $ea, $object, $getter)
{
$relation = $object->$getter();
if (!$relation) {
return false;
}
$changeSet = $ea->getObjectChangeSet($this->om->getUnitOfWork(), $relation);
if (isset($changeSet[$this->usedOptions['relationField']])) {
return true;
}
return $this->hasChangedParent($ea, $relation, $getter);
} | php | private function hasChangedParent(SluggableAdapter $ea, $object, $getter)
{
$relation = $object->$getter();
if (!$relation) {
return false;
}
$changeSet = $ea->getObjectChangeSet($this->om->getUnitOfWork(), $relation);
if (isset($changeSet[$this->usedOptions['relationField']])) {
return true;
}
return $this->hasChangedParent($ea, $relation, $getter);
} | [
"private",
"function",
"hasChangedParent",
"(",
"SluggableAdapter",
"$",
"ea",
",",
"$",
"object",
",",
"$",
"getter",
")",
"{",
"$",
"relation",
"=",
"$",
"object",
"->",
"$",
"getter",
"(",
")",
";",
"if",
"(",
"!",
"$",
"relation",
")",
"{",
"retu... | Check if the given object has a changed parent recursively
@param SluggableAdapter $ea
@param object $object
@param string $getter
@return bool | [
"Check",
"if",
"the",
"given",
"object",
"has",
"a",
"changed",
"parent",
"recursively"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Handler/RelativeSlugHandler.php#L52-L66 | train |
Opifer/Cms | src/CmsBundle/Controller/Backend/ContentController.php | ContentController.typeAction | public function typeAction($type)
{
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
if (!$contentType) {
throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
}
$queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')
->select('c', 'vs', 'v', 'a')
->leftJoin('c.valueSet', 'vs')
->leftJoin('vs.values', 'v')
->leftJoin('v.attribute', 'a');
$source = new Entity($this->getParameter('opifer_content.content_class'));
$source->initQueryBuilder($queryBuilder);
$tableAlias = $source->getTableAlias();
$source->manipulateQuery(function ($query) use ($tableAlias, $contentType) {
$query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
$query->andWhere($tableAlias . '.layout = :layout')->setParameter('layout', false);
});
$designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
$designAction->setRouteParameters(['id', 'owner' => 'content']);
$designAction->setRouteParametersMapping(['id' => 'ownerId']);
$detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
$detailsAction->setRouteParameters(['id']);
//$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
//$deleteAction->setRouteParameters(['id']);
/* @var $grid \APY\DataGridBundle\Grid\Grid */
$grid = $this->get('grid');
$grid->setId('content')
->setSource($source)
->addRowAction($detailsAction)
->addRowAction($designAction);
//->addRowAction($deleteAction)
foreach ($contentType->getSchema()->getAttributes() as $attribute) {
$name = $attribute->getName();
$column = new AttributeColumn([
'id' => $name,
'field' => 'valueSet.values.value',
'title' => $attribute->getDisplayName(),
'visible' => false,
'attribute' => $name,
'source' => true
]);
$column->manipulateRenderCell(
function ($value, $row, $router) use ($name) {
$value = $row->getEntity()->getAttributes()[$name];
return $value;
}
);
$grid->addColumn($column);
}
return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), [
'content_type' => $contentType,
'grid' => $grid,
]);
} | php | public function typeAction($type)
{
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
if (!$contentType) {
throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
}
$queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')
->select('c', 'vs', 'v', 'a')
->leftJoin('c.valueSet', 'vs')
->leftJoin('vs.values', 'v')
->leftJoin('v.attribute', 'a');
$source = new Entity($this->getParameter('opifer_content.content_class'));
$source->initQueryBuilder($queryBuilder);
$tableAlias = $source->getTableAlias();
$source->manipulateQuery(function ($query) use ($tableAlias, $contentType) {
$query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
$query->andWhere($tableAlias . '.layout = :layout')->setParameter('layout', false);
});
$designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
$designAction->setRouteParameters(['id', 'owner' => 'content']);
$designAction->setRouteParametersMapping(['id' => 'ownerId']);
$detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
$detailsAction->setRouteParameters(['id']);
//$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
//$deleteAction->setRouteParameters(['id']);
/* @var $grid \APY\DataGridBundle\Grid\Grid */
$grid = $this->get('grid');
$grid->setId('content')
->setSource($source)
->addRowAction($detailsAction)
->addRowAction($designAction);
//->addRowAction($deleteAction)
foreach ($contentType->getSchema()->getAttributes() as $attribute) {
$name = $attribute->getName();
$column = new AttributeColumn([
'id' => $name,
'field' => 'valueSet.values.value',
'title' => $attribute->getDisplayName(),
'visible' => false,
'attribute' => $name,
'source' => true
]);
$column->manipulateRenderCell(
function ($value, $row, $router) use ($name) {
$value = $row->getEntity()->getAttributes()[$name];
return $value;
}
);
$grid->addColumn($column);
}
return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), [
'content_type' => $contentType,
'grid' => $grid,
]);
} | [
"public",
"function",
"typeAction",
"(",
"$",
"type",
")",
"{",
"$",
"contentType",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.content_type_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!... | Index view of content by type
@param int $type
@return Response | [
"Index",
"view",
"of",
"content",
"by",
"type"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/ContentController.php#L22-L86 | train |
Th3Mouk/YahooWeatherAPI | src/YahooWeatherAPI.php | YahooWeatherAPI.getTemperature | public function getTemperature($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['item']['condition']['temp'])) {
return '';
}
$return = $this->lastResponse['item']['condition']['temp'];
if ($withUnit) {
$return .= ' '.$this->lastResponse['units']['temperature'];
}
return $return;
} | php | public function getTemperature($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['item']['condition']['temp'])) {
return '';
}
$return = $this->lastResponse['item']['condition']['temp'];
if ($withUnit) {
$return .= ' '.$this->lastResponse['units']['temperature'];
}
return $return;
} | [
"public",
"function",
"getTemperature",
"(",
"$",
"withUnit",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"lastResponse",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"lastResponse",
"[",
"'item'",
"]",
"[",
"'condition'",
"]",
"[",
"'tem... | Get current temperature.
@param bool $withUnit return or not the unit
@return string | [
"Get",
"current",
"temperature",
"."
] | 92d49d945d962b0a18272b8891f0134e79af1d51 | https://github.com/Th3Mouk/YahooWeatherAPI/blob/92d49d945d962b0a18272b8891f0134e79af1d51/src/YahooWeatherAPI.php#L143-L154 | train |
Th3Mouk/YahooWeatherAPI | src/YahooWeatherAPI.php | YahooWeatherAPI.getWind | public function getWind($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['wind']['speed'])) {
return array();
}
$response = array(
'chill' => $this->lastResponse['wind']['chill'],
'direction' => $this->lastResponse['wind']['direction'],
'speed' => $this->lastResponse['wind']['speed'],
);
if ($withUnit) {
$response['speed'] .= ' '.$this->lastResponse['units']['speed'];
}
return $response;
} | php | public function getWind($withUnit = false)
{
if (!$this->lastResponse || !isset($this->lastResponse['wind']['speed'])) {
return array();
}
$response = array(
'chill' => $this->lastResponse['wind']['chill'],
'direction' => $this->lastResponse['wind']['direction'],
'speed' => $this->lastResponse['wind']['speed'],
);
if ($withUnit) {
$response['speed'] .= ' '.$this->lastResponse['units']['speed'];
}
return $response;
} | [
"public",
"function",
"getWind",
"(",
"$",
"withUnit",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"lastResponse",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"lastResponse",
"[",
"'wind'",
"]",
"[",
"'speed'",
"]",
")",
")",
"{",
"r... | get Wind.
@param bool $withUnit return or not the unit
@return array | [
"get",
"Wind",
"."
] | 92d49d945d962b0a18272b8891f0134e79af1d51 | https://github.com/Th3Mouk/YahooWeatherAPI/blob/92d49d945d962b0a18272b8891f0134e79af1d51/src/YahooWeatherAPI.php#L191-L208 | train |
Opifer/Cms | src/MailingListBundle/Block/Service/SubscribeBlockService.php | SubscribeBlockService.subscribeAction | public function subscribeAction(Block $block)
{
$response = $this->execute($block);
$properties = $block->getProperties();
if ($this->subscribed && isset($properties['responseType']) && $properties['responseType'] == 'redirect') {
$content = $this->contentManager->getRepository()->find($properties['responseContent']);
$response = new RedirectResponse($this->router->generate('_content', ['slug' => $content->getSlug()]));
}
return $response;
} | php | public function subscribeAction(Block $block)
{
$response = $this->execute($block);
$properties = $block->getProperties();
if ($this->subscribed && isset($properties['responseType']) && $properties['responseType'] == 'redirect') {
$content = $this->contentManager->getRepository()->find($properties['responseContent']);
$response = new RedirectResponse($this->router->generate('_content', ['slug' => $content->getSlug()]));
}
return $response;
} | [
"public",
"function",
"subscribeAction",
"(",
"Block",
"$",
"block",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"block",
")",
";",
"$",
"properties",
"=",
"$",
"block",
"->",
"getProperties",
"(",
")",
";",
"if",
"(",
"$"... | Processes a POST request to subscribe.
@param Block $block
@return Response | [
"Processes",
"a",
"POST",
"request",
"to",
"subscribe",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Block/Service/SubscribeBlockService.php#L215-L226 | train |
Opifer/Cms | src/CmsBundle/Form/DataTransformer/SlugTransformer.php | SlugTransformer.transform | public function transform($slug)
{
if (null === $slug) {
return;
}
// If the slug ends with a slash, return just a slash
// so the item is used as the index page of that directory
if (substr($slug, -1) == '/') {
return '/';
}
$array = explode('/', $slug);
$slug = end($array);
return $slug;
} | php | public function transform($slug)
{
if (null === $slug) {
return;
}
// If the slug ends with a slash, return just a slash
// so the item is used as the index page of that directory
if (substr($slug, -1) == '/') {
return '/';
}
$array = explode('/', $slug);
$slug = end($array);
return $slug;
} | [
"public",
"function",
"transform",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"slug",
")",
"{",
"return",
";",
"}",
"// If the slug ends with a slash, return just a slash",
"// so the item is used as the index page of that directory",
"if",
"(",
"substr"... | Removes the directory path from the slug.
@param string $slug
@return string | [
"Removes",
"the",
"directory",
"path",
"from",
"the",
"slug",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Form/DataTransformer/SlugTransformer.php#L16-L32 | train |
Opifer/Cms | src/ContentBundle/Model/ContentTypeManager.php | ContentTypeManager.create | public function create()
{
$class = $this->getClass();
$contentType = new $class();
$schema = $this->schemaManager->create();
$schema->setObjectClass($this->contentManager->getClass());
$contentType->setSchema($schema);
return $contentType;
} | php | public function create()
{
$class = $this->getClass();
$contentType = new $class();
$schema = $this->schemaManager->create();
$schema->setObjectClass($this->contentManager->getClass());
$contentType->setSchema($schema);
return $contentType;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getClass",
"(",
")",
";",
"$",
"contentType",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"this",
"->",
"schemaManager",
"->",
"create",
"("... | Create a new contentType instance.
@return ContentType | [
"Create",
"a",
"new",
"contentType",
"instance",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentTypeManager.php#L56-L67 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.