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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
silverorange/swat | Swat/SwatCellRenderer.php | SwatCellRenderer.addCompositeRenderer | final protected function addCompositeRenderer(
SwatCellRenderer $renderer,
$key
) {
if (array_key_exists($key, $this->composite_renderers)) {
throw new SwatDuplicateIdException(
sprintf(
"A composite renderer with the key '%s' already exists in " .
"this renderer.",
$key
),
0,
$key
);
}
if ($renderer->parent !== null) {
throw new SwatException(
'Cannot add a composite renderer that ' .
'already has a parent.'
);
}
$this->composite_renderers[$key] = $renderer;
$renderer->parent = $this;
} | php | final protected function addCompositeRenderer(
SwatCellRenderer $renderer,
$key
) {
if (array_key_exists($key, $this->composite_renderers)) {
throw new SwatDuplicateIdException(
sprintf(
"A composite renderer with the key '%s' already exists in " .
"this renderer.",
$key
),
0,
$key
);
}
if ($renderer->parent !== null) {
throw new SwatException(
'Cannot add a composite renderer that ' .
'already has a parent.'
);
}
$this->composite_renderers[$key] = $renderer;
$renderer->parent = $this;
} | [
"final",
"protected",
"function",
"addCompositeRenderer",
"(",
"SwatCellRenderer",
"$",
"renderer",
",",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"composite_renderers",
")",
")",
"{",
"throw",
"new",
"Swat... | Adds a composite a renderer to this renderer
@param SwatCellRenderer $renderer the composite renderer to add.
@param string $key a key identifying the renderer so it may be retrieved
later. The key has to be unique within this renderer
relative to the keys of other composite renderers.
@throws SwatDuplicateIdException if a composite renderer with the
specified key is already added to this
renderer.
@throws SwatException if the specified renderer is already the child of
another object. | [
"Adds",
"a",
"composite",
"a",
"renderer",
"to",
"this",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L360-L385 | train |
silverorange/swat | Swat/SwatCellRenderer.php | SwatCellRenderer.getCompositeRenderer | final protected function getCompositeRenderer($key)
{
$this->confirmCompositeRenderers();
if (!array_key_exists($key, $this->composite_renderers)) {
throw new SwatWidgetNotFoundException(
sprintf(
"Composite renderer with key of '%s' not found in %s. Make " .
"sure the composite renderer was created and added to this " .
"renderer.",
$key,
get_class($this)
),
0,
$key
);
}
return $this->composite_renderers[$key];
} | php | final protected function getCompositeRenderer($key)
{
$this->confirmCompositeRenderers();
if (!array_key_exists($key, $this->composite_renderers)) {
throw new SwatWidgetNotFoundException(
sprintf(
"Composite renderer with key of '%s' not found in %s. Make " .
"sure the composite renderer was created and added to this " .
"renderer.",
$key,
get_class($this)
),
0,
$key
);
}
return $this->composite_renderers[$key];
} | [
"final",
"protected",
"function",
"getCompositeRenderer",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"confirmCompositeRenderers",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"composite_renderers",
")",
")",
... | Gets a composite renderer of this renderer by the composite renderer's
key
This is used by other methods to retrieve a specific composite renderer.
This method ensures composite renderers are created before trying to
retrieve the specified renderer.
@param string $key the key of the composite renderer to get.
@return SwatCellRenderer the specified composite renderer.
@throws SwatWidgetNotFoundException if no composite renderer with the
specified key exists in this
renderer. | [
"Gets",
"a",
"composite",
"renderer",
"of",
"this",
"renderer",
"by",
"the",
"composite",
"renderer",
"s",
"key"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L406-L425 | train |
silverorange/swat | Swat/SwatCellRenderer.php | SwatCellRenderer.getCompositeRenderers | final protected function getCompositeRenderers($class_name = null)
{
$this->confirmCompositeRenderers();
if (
!(
$class_name === null ||
class_exists($class_name) ||
interface_exists($class_name)
)
) {
return array();
}
$out = array();
foreach ($this->composite_renderers as $key => $renderer) {
if ($class_name === null || $renderer instanceof $class_name) {
$out[$key] = $renderer;
}
}
return $out;
} | php | final protected function getCompositeRenderers($class_name = null)
{
$this->confirmCompositeRenderers();
if (
!(
$class_name === null ||
class_exists($class_name) ||
interface_exists($class_name)
)
) {
return array();
}
$out = array();
foreach ($this->composite_renderers as $key => $renderer) {
if ($class_name === null || $renderer instanceof $class_name) {
$out[$key] = $renderer;
}
}
return $out;
} | [
"final",
"protected",
"function",
"getCompositeRenderers",
"(",
"$",
"class_name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"confirmCompositeRenderers",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"class_name",
"===",
"null",
"||",
"class_exists",
"(",
"$",
... | Gets all composite renderers added to this renderer
This method ensures composite renderers are created before retrieving
the renderers.
@param string $class_name optional class name. If set, only renderers
that are instances of <code>$class_name</code>
are returned.
@return array all composite wigets added to this renderer. The array is
indexed by the composite renderer keys.
@see SwatCellRenderer::addCompositeRenderer() | [
"Gets",
"all",
"composite",
"renderers",
"added",
"to",
"this",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L445-L468 | train |
silverorange/swat | Swat/SwatCellRenderer.php | SwatCellRenderer.makePropertyStatic | final protected function makePropertyStatic($property_name)
{
$reflector = new ReflectionObject($this);
if ($reflector->hasProperty($property_name)) {
$property = $reflector->getProperty($property_name);
if ($property->isPublic() && !$property->isStatic()) {
$this->static_properties[] = $property_name;
} else {
throw new SwatInvalidPropertyException(
"Property {$property_name} is not a non-static public " .
"property and cannot be made static.",
0,
$this,
$property_name
);
}
} else {
throw new SwatInvalidPropertyException(
"Can not make non-existant property {$property_name} static.",
0,
$this,
$property_name
);
}
} | php | final protected function makePropertyStatic($property_name)
{
$reflector = new ReflectionObject($this);
if ($reflector->hasProperty($property_name)) {
$property = $reflector->getProperty($property_name);
if ($property->isPublic() && !$property->isStatic()) {
$this->static_properties[] = $property_name;
} else {
throw new SwatInvalidPropertyException(
"Property {$property_name} is not a non-static public " .
"property and cannot be made static.",
0,
$this,
$property_name
);
}
} else {
throw new SwatInvalidPropertyException(
"Can not make non-existant property {$property_name} static.",
0,
$this,
$property_name
);
}
} | [
"final",
"protected",
"function",
"makePropertyStatic",
"(",
"$",
"property_name",
")",
"{",
"$",
"reflector",
"=",
"new",
"ReflectionObject",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"reflector",
"->",
"hasProperty",
"(",
"$",
"property_name",
")",
")",
... | Make a public property static
This method takes a property name and marks it as static, meaning that
a user can not data-map this property.
@param $property_name string the property name
@see SwatCellRenderer::isPropertyStatic()
@throws SwatInvalidPropertyException if the specified
<i>$property_name</i> is not a
non-static public property of
this class. | [
"Make",
"a",
"public",
"property",
"static"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L512-L536 | train |
brainworxx/kreXX | src/Analyse/Code/Codegen.php | Codegen.generateSource | public function generateSource(Model $model)
{
if ($this->allowCodegen === true) {
// We handle the first one special, because we need to add the original
// variable name to the source generation.
if ($this->firstRun === true) {
$this->firstRun = false;
return $this->concatenation($model);
}
// Test for constants.
// They have no connectors, but are marked as such.
// although this is meta stuff, we need to add the stop info here.
if ($model->getIsMetaConstants() === true) {
// We must only take the stuff from the constant itself
return ';stop;';
}
$connectors = $model->getConnectorLeft() . $model->getConnectorRight();
if (empty($connectors) === true) {
// No connectors, no nothing. We must be dealing with meta stuff.
// We will ignore this one.
return '';
}
// Debug methods are always public.
if ($model->getType() === static::TYPE_DEBUG_METHOD) {
return $this->concatenation($model);
}
// Multi line code generation starts here.
if ($model->getMultiLineCodeGen() === static::ITERATOR_TO_ARRAY) {
return 'iterator_to_array(;firstMarker;)' . $this->concatenation($model);
}
// Test for private or protected access.
if ($model->getIsPublic() === true) {
return $this->concatenation($model);
}
// Test if we are inside the scope. Everything within our scope is reachable.
if ($this->pool->scope->testModelForCodegen($model) === true) {
// We are inside the scope, this value, function or class is reachable.
return $this->concatenation($model);
}
// We are still here? Must be a protected method or property.
// The '. . .' will tell the code generation to stop in it's tracks
// and do nothing.
}
// No code generation in this path.
// We must prevent code generation when copying stuff here by recursion
// resolving by adding these dots.
return static::UNKNOWN_VALUE;
} | php | public function generateSource(Model $model)
{
if ($this->allowCodegen === true) {
// We handle the first one special, because we need to add the original
// variable name to the source generation.
if ($this->firstRun === true) {
$this->firstRun = false;
return $this->concatenation($model);
}
// Test for constants.
// They have no connectors, but are marked as such.
// although this is meta stuff, we need to add the stop info here.
if ($model->getIsMetaConstants() === true) {
// We must only take the stuff from the constant itself
return ';stop;';
}
$connectors = $model->getConnectorLeft() . $model->getConnectorRight();
if (empty($connectors) === true) {
// No connectors, no nothing. We must be dealing with meta stuff.
// We will ignore this one.
return '';
}
// Debug methods are always public.
if ($model->getType() === static::TYPE_DEBUG_METHOD) {
return $this->concatenation($model);
}
// Multi line code generation starts here.
if ($model->getMultiLineCodeGen() === static::ITERATOR_TO_ARRAY) {
return 'iterator_to_array(;firstMarker;)' . $this->concatenation($model);
}
// Test for private or protected access.
if ($model->getIsPublic() === true) {
return $this->concatenation($model);
}
// Test if we are inside the scope. Everything within our scope is reachable.
if ($this->pool->scope->testModelForCodegen($model) === true) {
// We are inside the scope, this value, function or class is reachable.
return $this->concatenation($model);
}
// We are still here? Must be a protected method or property.
// The '. . .' will tell the code generation to stop in it's tracks
// and do nothing.
}
// No code generation in this path.
// We must prevent code generation when copying stuff here by recursion
// resolving by adding these dots.
return static::UNKNOWN_VALUE;
} | [
"public",
"function",
"generateSource",
"(",
"Model",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"allowCodegen",
"===",
"true",
")",
"{",
"// We handle the first one special, because we need to add the original",
"// variable name to the source generation.",
"if"... | Generates PHP sourcecode.
From the 2 connectors and from the name of name/key of the attribute
we can generate PHP code to actually reach the corresponding value.
This function generates this code.
@param \Brainworxx\Krexx\Analyse\Model $model
The model, which hosts all the data we need.
@return string
The generated PHP source. | [
"Generates",
"PHP",
"sourcecode",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Code/Codegen.php#L102-L157 | train |
brainworxx/kreXX | src/Analyse/Code/Codegen.php | Codegen.concatenation | protected function concatenation(Model $model)
{
// We simply add the connectors for public access.
return $model->getConnectorLeft() .
$this->pool->encodingService->encodeStringForCodeGeneration($model->getName()) .
$model->getConnectorRight();
} | php | protected function concatenation(Model $model)
{
// We simply add the connectors for public access.
return $model->getConnectorLeft() .
$this->pool->encodingService->encodeStringForCodeGeneration($model->getName()) .
$model->getConnectorRight();
} | [
"protected",
"function",
"concatenation",
"(",
"Model",
"$",
"model",
")",
"{",
"// We simply add the connectors for public access.",
"return",
"$",
"model",
"->",
"getConnectorLeft",
"(",
")",
".",
"$",
"this",
"->",
"pool",
"->",
"encodingService",
"->",
"encodeSt... | Simple concatenation of all parameters.
@param \Brainworxx\Krexx\Analyse\Model $model
@return string
The generated code. | [
"Simple",
"concatenation",
"of",
"all",
"parameters",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Code/Codegen.php#L191-L197 | train |
silverorange/swat | Swat/SwatRadioTable.php | SwatRadioTable.displayRadioTableOption | protected function displayRadioTableOption(SwatOption $option, $index)
{
$tr_tag = $this->getTrTag($option, $index);
// add option-specific CSS classes from option metadata
$classes = $this->getOptionMetadata($option, 'classes');
if (is_array($classes)) {
$tr_tag->class = implode(' ', $classes);
} elseif ($classes) {
$tr_tag->class = strval($classes);
}
$tr_tag->open();
if ($option instanceof SwatFlydownDivider) {
echo '<td class="swat-radio-table-input">';
echo ' ';
echo '</td><td class="swat-radio-table-label">';
$this->displayDivider($option, $index);
echo '</td>';
} else {
echo '<td class="swat-radio-table-input">';
$this->displayOption($option, $index);
printf(
'</td><td id="%s" class="swat-radio-table-label">',
$this->id . '_' . (string) $option->value . '_label'
);
$this->displayOptionLabel($option, $index);
echo '</td>';
}
$tr_tag->close();
} | php | protected function displayRadioTableOption(SwatOption $option, $index)
{
$tr_tag = $this->getTrTag($option, $index);
// add option-specific CSS classes from option metadata
$classes = $this->getOptionMetadata($option, 'classes');
if (is_array($classes)) {
$tr_tag->class = implode(' ', $classes);
} elseif ($classes) {
$tr_tag->class = strval($classes);
}
$tr_tag->open();
if ($option instanceof SwatFlydownDivider) {
echo '<td class="swat-radio-table-input">';
echo ' ';
echo '</td><td class="swat-radio-table-label">';
$this->displayDivider($option, $index);
echo '</td>';
} else {
echo '<td class="swat-radio-table-input">';
$this->displayOption($option, $index);
printf(
'</td><td id="%s" class="swat-radio-table-label">',
$this->id . '_' . (string) $option->value . '_label'
);
$this->displayOptionLabel($option, $index);
echo '</td>';
}
$tr_tag->close();
} | [
"protected",
"function",
"displayRadioTableOption",
"(",
"SwatOption",
"$",
"option",
",",
"$",
"index",
")",
"{",
"$",
"tr_tag",
"=",
"$",
"this",
"->",
"getTrTag",
"(",
"$",
"option",
",",
"$",
"index",
")",
";",
"// add option-specific CSS classes from option... | Displays a single option in this radio table
@param SwatOption $option the option to display.
@param integer $index the numeric index of the option in this list.
Starts at 0. | [
"Displays",
"a",
"single",
"option",
"in",
"this",
"radio",
"table"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioTable.php#L74-L107 | train |
vaniocz/vanio-domain-bundle | Request/GetPostParamConverter.php | GetPostParamConverter.resolveRouteParameters | private function resolveRouteParameters(array $attributes): array
{
if (!isset($attributes['_route'])) {
return [];
}
$routeParameters = array_keys($attributes['_route_params']);
$routeParameters = array_combine($routeParameters, $routeParameters);
if (!$this->annotatedRouteControllerLoader) {
return $routeParameters;
}
// AnnotatedRouteControllerLoader from BeSimpleI18nRoutingBundle loads routes differently than the default one from Symfony.
// It populates _route_params with all default parameter values from controller action even with ones which placeholders are not present in route definition.
// The following workaround relies on the fact that URL generator generates URL with parameters which placeholders are not present in route definition as query string.
// @see https://github.com/BeSimple/BeSimpleI18nRoutingBundle/blob/83d2cf7c9ba6e6e3caed5d063b185ae54645eeee/src/Routing/Loader/AnnotatedRouteControllerLoader.php#L43
// @see https://github.com/symfony/symfony/blob/8ab7077225eadee444ba76c83c667688763c56fb/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php#L202
if ($this->configurableUrlGenerator) {
$isStrictRequirements = $this->configurableUrlGenerator->isStrictRequirements();
$this->configurableUrlGenerator->setStrictRequirements(null);
}
$url = $this->urlGenerator->generate($attributes['_route'], $routeParameters);
if (isset($isStrictRequirements)) {
$this->configurableUrlGenerator->setStrictRequirements($isStrictRequirements);
}
parse_str(parse_url($url, PHP_URL_QUERY), $additionalAttributes);
return array_diff_key($routeParameters, $additionalAttributes);
} | php | private function resolveRouteParameters(array $attributes): array
{
if (!isset($attributes['_route'])) {
return [];
}
$routeParameters = array_keys($attributes['_route_params']);
$routeParameters = array_combine($routeParameters, $routeParameters);
if (!$this->annotatedRouteControllerLoader) {
return $routeParameters;
}
// AnnotatedRouteControllerLoader from BeSimpleI18nRoutingBundle loads routes differently than the default one from Symfony.
// It populates _route_params with all default parameter values from controller action even with ones which placeholders are not present in route definition.
// The following workaround relies on the fact that URL generator generates URL with parameters which placeholders are not present in route definition as query string.
// @see https://github.com/BeSimple/BeSimpleI18nRoutingBundle/blob/83d2cf7c9ba6e6e3caed5d063b185ae54645eeee/src/Routing/Loader/AnnotatedRouteControllerLoader.php#L43
// @see https://github.com/symfony/symfony/blob/8ab7077225eadee444ba76c83c667688763c56fb/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php#L202
if ($this->configurableUrlGenerator) {
$isStrictRequirements = $this->configurableUrlGenerator->isStrictRequirements();
$this->configurableUrlGenerator->setStrictRequirements(null);
}
$url = $this->urlGenerator->generate($attributes['_route'], $routeParameters);
if (isset($isStrictRequirements)) {
$this->configurableUrlGenerator->setStrictRequirements($isStrictRequirements);
}
parse_str(parse_url($url, PHP_URL_QUERY), $additionalAttributes);
return array_diff_key($routeParameters, $additionalAttributes);
} | [
"private",
"function",
"resolveRouteParameters",
"(",
"array",
"$",
"attributes",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'_route'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"routeParameters",
"=",
"... | Returns an array of route parameters which placeholders arepresent in route definition.
@param mixed[] $attributes
@return string[] | [
"Returns",
"an",
"array",
"of",
"route",
"parameters",
"which",
"placeholders",
"arepresent",
"in",
"route",
"definition",
"."
] | 3eee57327c0a2f41f249868799b40505b5ef4717 | https://github.com/vaniocz/vanio-domain-bundle/blob/3eee57327c0a2f41f249868799b40505b5ef4717/Request/GetPostParamConverter.php#L103-L136 | train |
silverorange/swat | Swat/SwatControl.php | SwatControl.addMessage | public function addMessage(SwatMessage $message)
{
if ($this->parent instanceof SwatTitleable) {
$title = $this->parent->getTitle();
if ($title === null) {
$field_title = '';
} else {
if ($this->parent->getTitleContentType() === 'text/xml') {
$field_title =
'<strong>' . $this->parent->getTitle() . '</strong>';
} else {
$field_title =
'<strong>' .
SwatString::minimizeEntities(
$this->parent->getTitle()
) .
'</strong>';
}
}
} else {
$field_title = '';
}
if ($message->content_type === 'text/plain') {
$content = SwatString::minimizeEntities($message->primary_content);
} else {
$content = $message->primary_content;
}
$message->primary_content = sprintf($content, $field_title);
$message->content_type = 'text/xml';
parent::addMessage($message);
} | php | public function addMessage(SwatMessage $message)
{
if ($this->parent instanceof SwatTitleable) {
$title = $this->parent->getTitle();
if ($title === null) {
$field_title = '';
} else {
if ($this->parent->getTitleContentType() === 'text/xml') {
$field_title =
'<strong>' . $this->parent->getTitle() . '</strong>';
} else {
$field_title =
'<strong>' .
SwatString::minimizeEntities(
$this->parent->getTitle()
) .
'</strong>';
}
}
} else {
$field_title = '';
}
if ($message->content_type === 'text/plain') {
$content = SwatString::minimizeEntities($message->primary_content);
} else {
$content = $message->primary_content;
}
$message->primary_content = sprintf($content, $field_title);
$message->content_type = 'text/xml';
parent::addMessage($message);
} | [
"public",
"function",
"addMessage",
"(",
"SwatMessage",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"instanceof",
"SwatTitleable",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"parent",
"->",
"getTitle",
"(",
")",
";",
"if",
"(... | Adds a message to this control
Before the message is added, the content is updated with the name of
this controls's parent title field if the parent implements the
{@link SwatTitleable} interface.
@param SwatMessage $message the message to add.
@see SwatWidget::addMessage() | [
"Adds",
"a",
"message",
"to",
"this",
"control"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatControl.php#L25-L58 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughMethods.php | ThroughMethods.callMe | public function callMe()
{
$result = $this->dispatchStartEvent();
/** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $reflectionClass */
$reflectionClass = $this->parameters[static::PARAM_REF];
$commentAnalysis = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Methods');
// Deep analysis of the methods.
/** @var \ReflectionMethod $reflectionMethod */
foreach ($this->parameters[static::PARAM_DATA] as $reflectionMethod) {
$methodData = array();
// Get the comment from the class, it's parents, interfaces or traits.
$methodComment = $commentAnalysis->getComment($reflectionMethod, $reflectionClass);
if (empty($methodComment) === false) {
$methodData[static::META_COMMENT] = $methodComment;
}
// Get declaration place.
$declaringClass = $reflectionMethod->getDeclaringClass();
$methodData[static::META_DECLARED_IN] = $this->getDeclarationPlace($reflectionMethod, $declaringClass);
// Get parameters.
$paramList = '';
foreach ($reflectionMethod->getParameters() as $key => $reflectionParameter) {
++$key;
$paramList .= $methodData[static::META_PARAM_NO . $key] = $this->pool
->codegenHandler
->parameterToString($reflectionParameter);
// We add a comma to the parameter list, to separate them for a
// better readability.
$paramList .= ', ';
}
// Get declaring keywords.
$methodData['declaration keywords'] = $this->getDeclarationKeywords(
$reflectionMethod,
$declaringClass,
$reflectionClass
);
// Get the connector.
if ($reflectionMethod->isStatic() === true) {
$connectorType = Connectors::STATIC_METHOD;
} else {
$connectorType = Connectors::METHOD;
}
// Update the reflection method, so an event subscriber can do
// something with it.
$this->parameters[static::PARAM_REF_METHOD] = $reflectionMethod;
// Render it!
$result .= $this->pool->render->renderExpandableChild(
$this->dispatchEventWithModel(
__FUNCTION__ . static::EVENT_MARKER_END,
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setName($reflectionMethod->name)
->setType($methodData['declaration keywords'] . static::TYPE_METHOD)
->setConnectorType($connectorType)
// Remove the ',' after the last char.
->setConnectorParameters(trim($paramList, ', '))
->addParameter(static::PARAM_DATA, $methodData)
->setIsPublic($reflectionMethod->isPublic())
->injectCallback(
$this->pool->createClass(
'Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughMethodAnalysis'
)
)
)
);
}
return $result;
} | php | public function callMe()
{
$result = $this->dispatchStartEvent();
/** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $reflectionClass */
$reflectionClass = $this->parameters[static::PARAM_REF];
$commentAnalysis = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Methods');
// Deep analysis of the methods.
/** @var \ReflectionMethod $reflectionMethod */
foreach ($this->parameters[static::PARAM_DATA] as $reflectionMethod) {
$methodData = array();
// Get the comment from the class, it's parents, interfaces or traits.
$methodComment = $commentAnalysis->getComment($reflectionMethod, $reflectionClass);
if (empty($methodComment) === false) {
$methodData[static::META_COMMENT] = $methodComment;
}
// Get declaration place.
$declaringClass = $reflectionMethod->getDeclaringClass();
$methodData[static::META_DECLARED_IN] = $this->getDeclarationPlace($reflectionMethod, $declaringClass);
// Get parameters.
$paramList = '';
foreach ($reflectionMethod->getParameters() as $key => $reflectionParameter) {
++$key;
$paramList .= $methodData[static::META_PARAM_NO . $key] = $this->pool
->codegenHandler
->parameterToString($reflectionParameter);
// We add a comma to the parameter list, to separate them for a
// better readability.
$paramList .= ', ';
}
// Get declaring keywords.
$methodData['declaration keywords'] = $this->getDeclarationKeywords(
$reflectionMethod,
$declaringClass,
$reflectionClass
);
// Get the connector.
if ($reflectionMethod->isStatic() === true) {
$connectorType = Connectors::STATIC_METHOD;
} else {
$connectorType = Connectors::METHOD;
}
// Update the reflection method, so an event subscriber can do
// something with it.
$this->parameters[static::PARAM_REF_METHOD] = $reflectionMethod;
// Render it!
$result .= $this->pool->render->renderExpandableChild(
$this->dispatchEventWithModel(
__FUNCTION__ . static::EVENT_MARKER_END,
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setName($reflectionMethod->name)
->setType($methodData['declaration keywords'] . static::TYPE_METHOD)
->setConnectorType($connectorType)
// Remove the ',' after the last char.
->setConnectorParameters(trim($paramList, ', '))
->addParameter(static::PARAM_DATA, $methodData)
->setIsPublic($reflectionMethod->isPublic())
->injectCallback(
$this->pool->createClass(
'Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughMethodAnalysis'
)
)
)
);
}
return $result;
} | [
"public",
"function",
"callMe",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"dispatchStartEvent",
"(",
")",
";",
"/** @var \\Brainworxx\\Krexx\\Service\\Reflection\\ReflectionClass $reflectionClass */",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"paramete... | Simply start to iterate through the methods.
@return string
The rendered markup. | [
"Simply",
"start",
"to",
"iterate",
"through",
"the",
"methods",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughMethods.php#L63-L137 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughMethods.php | ThroughMethods.getDeclarationPlace | protected function getDeclarationPlace(\ReflectionMethod $reflectionMethod, \ReflectionClass $declaringClass)
{
$filename = $this->pool->fileService->filterFilePath($reflectionMethod->getFileName());
if (empty($filename) === true) {
return static::UNKNOWN_DECLARATION;
}
// If the filename of the $declaringClass and the $reflectionMethod differ,
// we are facing a trait here.
if ($reflectionMethod->getFileName() !== $declaringClass->getFileName() &&
method_exists($declaringClass, 'getTraits')
) {
// There is no real clean way to get the name of the trait that we
// are looking at.
$traitName = ':: unable to get the trait name ::';
$trait = $this->retrieveDeclaringReflection($reflectionMethod, $declaringClass);
if ($trait !== false) {
$traitName = $trait->getName();
}
return $filename . "\n" .
'in trait: ' . $traitName . "\n" .
'in line: ' . $reflectionMethod->getStartLine();
} else {
return $filename . "\n" .
'in class: ' . $reflectionMethod->class . "\n" .
'in line: ' . $reflectionMethod->getStartLine();
}
} | php | protected function getDeclarationPlace(\ReflectionMethod $reflectionMethod, \ReflectionClass $declaringClass)
{
$filename = $this->pool->fileService->filterFilePath($reflectionMethod->getFileName());
if (empty($filename) === true) {
return static::UNKNOWN_DECLARATION;
}
// If the filename of the $declaringClass and the $reflectionMethod differ,
// we are facing a trait here.
if ($reflectionMethod->getFileName() !== $declaringClass->getFileName() &&
method_exists($declaringClass, 'getTraits')
) {
// There is no real clean way to get the name of the trait that we
// are looking at.
$traitName = ':: unable to get the trait name ::';
$trait = $this->retrieveDeclaringReflection($reflectionMethod, $declaringClass);
if ($trait !== false) {
$traitName = $trait->getName();
}
return $filename . "\n" .
'in trait: ' . $traitName . "\n" .
'in line: ' . $reflectionMethod->getStartLine();
} else {
return $filename . "\n" .
'in class: ' . $reflectionMethod->class . "\n" .
'in line: ' . $reflectionMethod->getStartLine();
}
} | [
"protected",
"function",
"getDeclarationPlace",
"(",
"\\",
"ReflectionMethod",
"$",
"reflectionMethod",
",",
"\\",
"ReflectionClass",
"$",
"declaringClass",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"pool",
"->",
"fileService",
"->",
"filterFilePath",
"("... | Get the declaration place of this method.
@param \ReflectionMethod $reflectionMethod
Reflection of the method we are analysing.
@param \ReflectionClass $declaringClass
Reflection of the class we are analysing
@return string
The analysis result. | [
"Get",
"the",
"declaration",
"place",
"of",
"this",
"method",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughMethods.php#L150-L178 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughMethods.php | ThroughMethods.retrieveDeclaringReflection | protected function retrieveDeclaringReflection(
\ReflectionMethod $reflectionMethod,
\ReflectionClass $declaringClass
) {
// Get a first impression.
if ($reflectionMethod->getFileName() === $declaringClass->getFileName()) {
return $declaringClass;
}
// Go through the first layer of traits.
// No need to recheck the availability for traits. This is done above.
foreach ($declaringClass->getTraits() as $trait) {
$result = $this->retrieveDeclaringReflection($reflectionMethod, $trait);
if ($result !== false) {
return $result;
}
}
return false;
} | php | protected function retrieveDeclaringReflection(
\ReflectionMethod $reflectionMethod,
\ReflectionClass $declaringClass
) {
// Get a first impression.
if ($reflectionMethod->getFileName() === $declaringClass->getFileName()) {
return $declaringClass;
}
// Go through the first layer of traits.
// No need to recheck the availability for traits. This is done above.
foreach ($declaringClass->getTraits() as $trait) {
$result = $this->retrieveDeclaringReflection($reflectionMethod, $trait);
if ($result !== false) {
return $result;
}
}
return false;
} | [
"protected",
"function",
"retrieveDeclaringReflection",
"(",
"\\",
"ReflectionMethod",
"$",
"reflectionMethod",
",",
"\\",
"ReflectionClass",
"$",
"declaringClass",
")",
"{",
"// Get a first impression.",
"if",
"(",
"$",
"reflectionMethod",
"->",
"getFileName",
"(",
")"... | Retrieve the declaration class reflection from traits.
@param \ReflectionMethod $reflectionMethod
The reflection of the method we are analysing.
@param \ReflectionClass $declaringClass
The original declaring class, the one with the traits.
@return bool|\ReflectionClass
false = unable to retrieve someting.
Otherwise return a reflection class. | [
"Retrieve",
"the",
"declaration",
"class",
"reflection",
"from",
"traits",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughMethods.php#L192-L211 | train |
silverorange/swat | Swat/SwatTableViewRow.php | SwatTableViewRow.getHtmlHeadEntrySet | public function getHtmlHeadEntrySet()
{
if ($this->isDisplayed()) {
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
} else {
$set = new SwatHtmlHeadEntrySet();
}
return $set;
} | php | public function getHtmlHeadEntrySet()
{
if ($this->isDisplayed()) {
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
} else {
$set = new SwatHtmlHeadEntrySet();
}
return $set;
} | [
"public",
"function",
"getHtmlHeadEntrySet",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDisplayed",
"(",
")",
")",
"{",
"$",
"set",
"=",
"new",
"SwatHtmlHeadEntrySet",
"(",
"$",
"this",
"->",
"html_head_entry_set",
")",
";",
"}",
"else",
"{",
"$",
... | Gets the SwatHtmlHeadEntry objects needed by this row
If this row has not been displayed, an empty set is returned to reduce
the number of required HTTP requests.
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by
this row. | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"needed",
"by",
"this",
"row"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewRow.php#L166-L175 | train |
TeknooSoftware/states | demo/Acme/Extendable/Mother/Mother.php | Mother.listAvailableStates | public function listAvailableStates(): array
{
if (!empty($this->states) && \is_array($this->states)) {
return \array_keys($this->states);
} else {
return [];
}
} | php | public function listAvailableStates(): array
{
if (!empty($this->states) && \is_array($this->states)) {
return \array_keys($this->states);
} else {
return [];
}
} | [
"public",
"function",
"listAvailableStates",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"states",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"states",
")",
")",
"{",
"return",
"\\",
"array_keys",
"(",
"$",... | Return the list of registered states. Present only for debug and tests | [
"Return",
"the",
"list",
"of",
"registered",
"states",
".",
"Present",
"only",
"for",
"debug",
"and",
"tests"
] | 0c675b768781ee3a3a15c2663cffec5d50c1d5fd | https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/demo/Acme/Extendable/Mother/Mother.php#L62-L69 | train |
silverorange/swat | demo/include/DemoApplication.php | DemoApplication.getDemo | private function getDemo()
{
$demo = isset($_GET['demo']) ? $_GET['demo'] : null;
// simple security
if (!array_key_exists($demo, $this->available_demos))
$demo = null;
return $demo;
} | php | private function getDemo()
{
$demo = isset($_GET['demo']) ? $_GET['demo'] : null;
// simple security
if (!array_key_exists($demo, $this->available_demos))
$demo = null;
return $demo;
} | [
"private",
"function",
"getDemo",
"(",
")",
"{",
"$",
"demo",
"=",
"isset",
"(",
"$",
"_GET",
"[",
"'demo'",
"]",
")",
"?",
"$",
"_GET",
"[",
"'demo'",
"]",
":",
"null",
";",
"// simple security",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"demo",... | Gets the demo page | [
"Gets",
"the",
"demo",
"page"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/demo/include/DemoApplication.php#L494-L503 | train |
silverorange/swat | Swat/SwatFrame.php | SwatFrame.getTitle | public function getTitle()
{
if ($this->subtitle === null) {
return $this->title;
}
if ($this->title === null) {
return $this->subtitle;
}
return $this->title . ': ' . $this->subtitle;
} | php | public function getTitle()
{
if ($this->subtitle === null) {
return $this->title;
}
if ($this->title === null) {
return $this->subtitle;
}
return $this->title . ': ' . $this->subtitle;
} | [
"public",
"function",
"getTitle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"subtitle",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"title",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"title",
"===",
"null",
")",
"{",
"return",
"$",
"th... | Gets the title of this frame
Implements the {@link SwatTitleable::getTitle()} interface.
@return string the title of this frame. | [
"Gets",
"the",
"title",
"of",
"this",
"frame"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFrame.php#L64-L75 | train |
silverorange/swat | Swat/SwatFrame.php | SwatFrame.display | public function display()
{
if (!$this->visible) {
return;
}
SwatWidget::display();
$outer_div = new SwatHtmlTag('div');
$outer_div->id = $this->id;
$outer_div->class = $this->getCSSClassString();
$outer_div->open();
$this->displayTitle();
$this->displayContent();
$outer_div->close();
} | php | public function display()
{
if (!$this->visible) {
return;
}
SwatWidget::display();
$outer_div = new SwatHtmlTag('div');
$outer_div->id = $this->id;
$outer_div->class = $this->getCSSClassString();
$outer_div->open();
$this->displayTitle();
$this->displayContent();
$outer_div->close();
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"SwatWidget",
"::",
"display",
"(",
")",
";",
"$",
"outer_div",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
"out... | Displays this frame | [
"Displays",
"this",
"frame"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFrame.php#L98-L114 | train |
silverorange/swat | Swat/SwatFrame.php | SwatFrame.displayTitle | protected function displayTitle()
{
if ($this->title !== null) {
$header_tag = new SwatHtmlTag('h' . $this->getHeaderLevel());
$header_tag->class = 'swat-frame-title';
$header_tag->setContent($this->title, $this->title_content_type);
if ($this->subtitle === null) {
$header_tag->display();
} else {
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-frame-subtitle';
$span_tag->setContent(
$this->subtitle,
$this->title_content_type
);
$header_tag->open();
$header_tag->displayContent();
echo $this->title_separator;
$span_tag->display();
$header_tag->close();
}
}
} | php | protected function displayTitle()
{
if ($this->title !== null) {
$header_tag = new SwatHtmlTag('h' . $this->getHeaderLevel());
$header_tag->class = 'swat-frame-title';
$header_tag->setContent($this->title, $this->title_content_type);
if ($this->subtitle === null) {
$header_tag->display();
} else {
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-frame-subtitle';
$span_tag->setContent(
$this->subtitle,
$this->title_content_type
);
$header_tag->open();
$header_tag->displayContent();
echo $this->title_separator;
$span_tag->display();
$header_tag->close();
}
}
} | [
"protected",
"function",
"displayTitle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"title",
"!==",
"null",
")",
"{",
"$",
"header_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'h'",
".",
"$",
"this",
"->",
"getHeaderLevel",
"(",
")",
")",
";",
"$",
"head... | Displays this frame's title | [
"Displays",
"this",
"frame",
"s",
"title"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFrame.php#L122-L146 | train |
silverorange/swat | Swat/SwatFrame.php | SwatFrame.displayContent | protected function displayContent()
{
$inner_div = new SwatHtmlTag('div');
$inner_div->class = 'swat-frame-contents';
$inner_div->open();
$this->displayChildren();
$inner_div->close();
} | php | protected function displayContent()
{
$inner_div = new SwatHtmlTag('div');
$inner_div->class = 'swat-frame-contents';
$inner_div->open();
$this->displayChildren();
$inner_div->close();
} | [
"protected",
"function",
"displayContent",
"(",
")",
"{",
"$",
"inner_div",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
"inner_div",
"->",
"class",
"=",
"'swat-frame-contents'",
";",
"$",
"inner_div",
"->",
"open",
"(",
")",
";",
"$",
"this",
... | Displays this frame's content | [
"Displays",
"this",
"frame",
"s",
"content"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFrame.php#L154-L161 | train |
honey-comb/core | src/Http/Requests/HCUserRequest.php | HCUserRequest.getUserInput | public function getUserInput(): array
{
$data = [
'email' => $this->input('email'),
'is_active' => $this->filled('is_active') ? 1 : 0,
];
if ($this->input('password')) {
Arr::set($data, 'password', $this->input('password'));
}
return $data;
} | php | public function getUserInput(): array
{
$data = [
'email' => $this->input('email'),
'is_active' => $this->filled('is_active') ? 1 : 0,
];
if ($this->input('password')) {
Arr::set($data, 'password', $this->input('password'));
}
return $data;
} | [
"public",
"function",
"getUserInput",
"(",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"'email'",
"=>",
"$",
"this",
"->",
"input",
"(",
"'email'",
")",
",",
"'is_active'",
"=>",
"$",
"this",
"->",
"filled",
"(",
"'is_active'",
")",
"?",
"1",
":",... | Get request inputs
@return array | [
"Get",
"request",
"inputs"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Http/Requests/HCUserRequest.php#L46-L58 | train |
honey-comb/core | src/Http/Requests/HCUserRequest.php | HCUserRequest.getPersonalData | public function getPersonalData(): array
{
$photo = $this->input('photo_id');
if (is_array($photo) && !$photo) {
$photo = null;
}
return [
'first_name' => $this->input('first_name'),
'last_name' => $this->input('last_name'),
'photo_id' => $photo,
'description' => $this->input('description'),
'phone' => $this->input('phone'),
'address' => $this->input('address'),
'notification_email' => $this->input('notification_email'),
];
} | php | public function getPersonalData(): array
{
$photo = $this->input('photo_id');
if (is_array($photo) && !$photo) {
$photo = null;
}
return [
'first_name' => $this->input('first_name'),
'last_name' => $this->input('last_name'),
'photo_id' => $photo,
'description' => $this->input('description'),
'phone' => $this->input('phone'),
'address' => $this->input('address'),
'notification_email' => $this->input('notification_email'),
];
} | [
"public",
"function",
"getPersonalData",
"(",
")",
":",
"array",
"{",
"$",
"photo",
"=",
"$",
"this",
"->",
"input",
"(",
"'photo_id'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"photo",
")",
"&&",
"!",
"$",
"photo",
")",
"{",
"$",
"photo",
"=",
... | Get personal info
@return array | [
"Get",
"personal",
"info"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Http/Requests/HCUserRequest.php#L83-L100 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.process | public function process()
{
if (!$this->isInitialized()) {
$this->init();
}
foreach ($this->getCompositeWidgets() as $widget) {
$widget->process();
}
$this->processed = true;
} | php | public function process()
{
if (!$this->isInitialized()) {
$this->init();
}
foreach ($this->getCompositeWidgets() as $widget) {
$widget->process();
}
$this->processed = true;
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isInitialized",
"(",
")",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getCompositeWidgets",
"(",
")",
"as",
"$",
... | Processes this widget
After a form submit, this widget processes itself and its dependencies
and then recursively processes any of its child widgets.
Composite widgets of this widget are automatically processed as well.
If this widget has not been initialized, it is automatically initialized
before processing. | [
"Processes",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L208-L219 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.getHtmlHeadEntrySet | public function getHtmlHeadEntrySet()
{
if ($this->isDisplayed()) {
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
} else {
$set = new SwatHtmlHeadEntrySet();
}
foreach ($this->getCompositeWidgets() as $widget) {
$set->addEntrySet($widget->getHtmlHeadEntrySet());
}
return $set;
} | php | public function getHtmlHeadEntrySet()
{
if ($this->isDisplayed()) {
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
} else {
$set = new SwatHtmlHeadEntrySet();
}
foreach ($this->getCompositeWidgets() as $widget) {
$set->addEntrySet($widget->getHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getHtmlHeadEntrySet",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDisplayed",
"(",
")",
")",
"{",
"$",
"set",
"=",
"new",
"SwatHtmlHeadEntrySet",
"(",
"$",
"this",
"->",
"html_head_entry_set",
")",
";",
"}",
"else",
"{",
"$",
... | Gets the SwatHtmlHeadEntry objects needed by this widget
If this widget has not been displayed, an empty set is returned to
reduce the number of required HTTP requests.
@return SwatHtmlHeadEntrySet the {@link SwatHtmlHeadEntry} objects
needed by this widget. | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"needed",
"by",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L269-L282 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.getAvailableHtmlHeadEntrySet | public function getAvailableHtmlHeadEntrySet()
{
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
foreach ($this->getCompositeWidgets() as $widget) {
$set->addEntrySet($widget->getAvailableHtmlHeadEntrySet());
}
return $set;
} | php | public function getAvailableHtmlHeadEntrySet()
{
$set = new SwatHtmlHeadEntrySet($this->html_head_entry_set);
foreach ($this->getCompositeWidgets() as $widget) {
$set->addEntrySet($widget->getAvailableHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getAvailableHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"new",
"SwatHtmlHeadEntrySet",
"(",
"$",
"this",
"->",
"html_head_entry_set",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCompositeWidgets",
"(",
")",
"as",
"$",
"widget... | Gets the SwatHtmlHeadEntry objects that may be needed by this widget
@return SwatHtmlHeadEntrySet the {@link SwatHtmlHeadEntry} objects that
may be needed by this widget. | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"that",
"may",
"be",
"needed",
"by",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L293-L302 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.isSensitive | public function isSensitive()
{
if ($this->parent !== null && $this->parent instanceof SwatWidget) {
return $this->parent->isSensitive() && $this->sensitive;
} else {
return $this->sensitive;
}
} | php | public function isSensitive()
{
if ($this->parent !== null && $this->parent instanceof SwatWidget) {
return $this->parent->isSensitive() && $this->sensitive;
} else {
return $this->sensitive;
}
} | [
"public",
"function",
"isSensitive",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"!==",
"null",
"&&",
"$",
"this",
"->",
"parent",
"instanceof",
"SwatWidget",
")",
"{",
"return",
"$",
"this",
"->",
"parent",
"->",
"isSensitive",
"(",
")",
"&... | Determines the sensitivity of this widget.
Looks at the sensitive property of the ancestors of this widget to
determine if this widget is sensitive.
@return boolean whether this widget is sensitive.
@see SwatWidget::$sensitive | [
"Determines",
"the",
"sensitivity",
"of",
"this",
"widget",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L381-L388 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.replaceWithContainer | public function replaceWithContainer(SwatContainer $container = null)
{
if ($this->parent === null) {
throw new SwatException(
'Widget does not have a parent, unable ' .
'to replace this widget with a container.'
);
}
if ($container === null) {
$container = new SwatContainer();
}
$parent = $this->parent;
$parent->replace($this, $container);
$container->add($this);
return $container;
} | php | public function replaceWithContainer(SwatContainer $container = null)
{
if ($this->parent === null) {
throw new SwatException(
'Widget does not have a parent, unable ' .
'to replace this widget with a container.'
);
}
if ($container === null) {
$container = new SwatContainer();
}
$parent = $this->parent;
$parent->replace($this, $container);
$container->add($this);
return $container;
} | [
"public",
"function",
"replaceWithContainer",
"(",
"SwatContainer",
"$",
"container",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"'Widget does not have a parent, unable '",
".",
"... | Replace this widget with a new container
Replaces this widget in the widget tree with a new {@link SwatContainer},
then adds this widget to the new container.
@param SwatContainer $container optional container to use
@throws SwatException
@return SwatContainer a reference to the new container. | [
"Replace",
"this",
"widget",
"with",
"a",
"new",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L469-L487 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.getCSSClassNames | protected function getCSSClassNames()
{
$classes = array();
if (!$this->isSensitive()) {
$classes[] = 'swat-insensitive';
}
$classes = array_merge($classes, parent::getCSSClassNames());
return $classes;
} | php | protected function getCSSClassNames()
{
$classes = array();
if (!$this->isSensitive()) {
$classes[] = 'swat-insensitive';
}
$classes = array_merge($classes, parent::getCSSClassNames());
return $classes;
} | [
"protected",
"function",
"getCSSClassNames",
"(",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isSensitive",
"(",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'swat-insensitive'",
";",
"}",
"$",
"classe... | Gets the array of CSS classes that are applied to this widget
@return array the array of CSS classes that are applied to this widget. | [
"Gets",
"the",
"array",
"of",
"CSS",
"classes",
"that",
"are",
"applied",
"to",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L539-L550 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.addCompositeWidget | final protected function addCompositeWidget(SwatWidget $widget, $key)
{
if (array_key_exists($key, $this->composite_widgets)) {
throw new SwatDuplicateIdException(
sprintf(
"A composite widget with the key '%s' already exists in this " .
"widget.",
$key
),
0,
$key
);
}
if ($widget->parent !== null) {
throw new SwatException(
'Cannot add a composite widget that already has a parent.'
);
}
$this->composite_widgets[$key] = $widget;
$widget->parent = $this;
} | php | final protected function addCompositeWidget(SwatWidget $widget, $key)
{
if (array_key_exists($key, $this->composite_widgets)) {
throw new SwatDuplicateIdException(
sprintf(
"A composite widget with the key '%s' already exists in this " .
"widget.",
$key
),
0,
$key
);
}
if ($widget->parent !== null) {
throw new SwatException(
'Cannot add a composite widget that already has a parent.'
);
}
$this->composite_widgets[$key] = $widget;
$widget->parent = $this;
} | [
"final",
"protected",
"function",
"addCompositeWidget",
"(",
"SwatWidget",
"$",
"widget",
",",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"composite_widgets",
")",
")",
"{",
"throw",
"new",
"SwatDuplicateIdE... | Adds a composite a widget to this widget
@param SwatWidget $widget the composite widget to add.
@param string $key a key identifying the widget so it may be retrieved
later. The key does not have to be the widget's id
but the key does have to be unique within this
widget relative to the keys of other composite
widgets.
@throws SwatDuplicateIdException if a composite widget with the
specified key is already added to this
widget.
@throws SwatException if the specified widget is already the child of
another object. | [
"Adds",
"a",
"composite",
"a",
"widget",
"to",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L584-L606 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.getCompositeWidget | final protected function getCompositeWidget($key)
{
$this->confirmCompositeWidgets();
if (!array_key_exists($key, $this->composite_widgets)) {
throw new SwatWidgetNotFoundException(
sprintf(
"Composite widget with key of '%s' not found in %s. Make sure " .
"the composite widget was created and added to this widget.",
$key,
get_class($this)
),
0,
$key
);
}
return $this->composite_widgets[$key];
} | php | final protected function getCompositeWidget($key)
{
$this->confirmCompositeWidgets();
if (!array_key_exists($key, $this->composite_widgets)) {
throw new SwatWidgetNotFoundException(
sprintf(
"Composite widget with key of '%s' not found in %s. Make sure " .
"the composite widget was created and added to this widget.",
$key,
get_class($this)
),
0,
$key
);
}
return $this->composite_widgets[$key];
} | [
"final",
"protected",
"function",
"getCompositeWidget",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"confirmCompositeWidgets",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"composite_widgets",
")",
")",
"{",... | Gets a composite widget of this widget by the composite widget's key
This is used by other methods to retrieve a specific composite widget.
This method ensures composite widgets are created before trying to
retrieve the specified widget.
@param string $key the key of the composite widget to get.
@return SwatWidget the specified composite widget.
@throws SwatWidgetNotFoundException if no composite widget with the
specified key exists in this widget. | [
"Gets",
"a",
"composite",
"widget",
"of",
"this",
"widget",
"by",
"the",
"composite",
"widget",
"s",
"key"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L625-L643 | train |
silverorange/swat | Swat/SwatWidget.php | SwatWidget.getCompositeWidgets | final protected function getCompositeWidgets($class_name = null)
{
$this->confirmCompositeWidgets();
if (
!(
$class_name === null ||
class_exists($class_name) ||
interface_exists($class_name)
)
) {
return array();
}
$out = array();
foreach ($this->composite_widgets as $key => $widget) {
if ($class_name === null || $widget instanceof $class_name) {
$out[$key] = $widget;
}
}
return $out;
} | php | final protected function getCompositeWidgets($class_name = null)
{
$this->confirmCompositeWidgets();
if (
!(
$class_name === null ||
class_exists($class_name) ||
interface_exists($class_name)
)
) {
return array();
}
$out = array();
foreach ($this->composite_widgets as $key => $widget) {
if ($class_name === null || $widget instanceof $class_name) {
$out[$key] = $widget;
}
}
return $out;
} | [
"final",
"protected",
"function",
"getCompositeWidgets",
"(",
"$",
"class_name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"confirmCompositeWidgets",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"class_name",
"===",
"null",
"||",
"class_exists",
"(",
"$",
"cla... | Gets all composite widgets added to this widget
This method ensures composite widgets are created before retrieving the
widgets.
@param string $class_name optional class name. If set, only widgets
that are instances of <code>$class_name</code>
are returned.
@return array all composite wigets added to this widget. The array is
indexed by the composite widget keys.
@see SwatWidget::addCompositeWidget() | [
"Gets",
"all",
"composite",
"widgets",
"added",
"to",
"this",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidget.php#L663-L686 | train |
brainworxx/kreXX | src/Service/Flow/Recursion.php | Recursion.isInHive | public function isInHive($bee)
{
// Check objects.
if (is_object($bee) === true) {
return $this->recursionHive->contains($bee);
}
// Check arrays (only the $GLOBAL array may apply).
if (isset($bee[$this->recursionMarker]) === true) {
// We render the $GLOBALS only once.
if ($this->globalsWereRendered === true) {
return true;
}
$this->globalsWereRendered = true;
}
// Should be a normal array. We do not track these, because we can not
// resolve them via JS recursion handling.
return false;
} | php | public function isInHive($bee)
{
// Check objects.
if (is_object($bee) === true) {
return $this->recursionHive->contains($bee);
}
// Check arrays (only the $GLOBAL array may apply).
if (isset($bee[$this->recursionMarker]) === true) {
// We render the $GLOBALS only once.
if ($this->globalsWereRendered === true) {
return true;
}
$this->globalsWereRendered = true;
}
// Should be a normal array. We do not track these, because we can not
// resolve them via JS recursion handling.
return false;
} | [
"public",
"function",
"isInHive",
"(",
"$",
"bee",
")",
"{",
"// Check objects.",
"if",
"(",
"is_object",
"(",
"$",
"bee",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"recursionHive",
"->",
"contains",
"(",
"$",
"bee",
")",
";",
"}",
"... | Find out if our bee is already in the hive.
@param object|array $bee
The object or array we want to check for recursion.
@return bool
Boolean which shows whether we are facing a recursion. | [
"Find",
"out",
"if",
"our",
"bee",
"is",
"already",
"in",
"the",
"hive",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Flow/Recursion.php#L135-L155 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$flydown = $this->getCompositeWidget('action_flydown');
foreach ($this->action_items as $item) {
if ($item->visible) {
if ($item instanceof SwatActionItemDivider) {
$flydown->addDivider();
} else {
$flydown->addOption($item->id, $item->title);
}
}
}
// set the flydown back to its initial state (no persistence). The
// flydown is never reset if there is a selected item and the selected
// items has a widget with one or more messages.
if (
$this->auto_reset &&
($this->selected === null ||
$this->selected->widget === null ||
!$this->selected->widget->hasMessage())
) {
$flydown->reset();
}
// select the current action item based upon the flydown value
if (isset($this->action_items_by_id[$flydown->value])) {
$this->selected = $this->action_items_by_id[$flydown->value];
} else {
$this->selected = null;
}
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
echo '<div class="swat-actions-controls">';
$label = new SwatHtmlTag('label');
$label->for = $flydown->getFocusableHtmlId();
$label->setContent(Swat::_('Action: '));
$label->display();
$flydown->display();
echo ' ';
$this->displayButton();
echo '</div>';
foreach ($this->action_items as $item) {
if ($item->widget !== null) {
$div = new SwatHtmlTag('div');
$div->class =
$item == $this->selected ? 'swat-visible' : 'swat-hidden';
$div->id = $this->id . '_' . $item->id;
$div->open();
$item->display();
$div->close();
}
}
echo '<div class="swat-actions-note">';
echo Swat::_('Actions apply to checked items.');
echo '</div>';
$div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$flydown = $this->getCompositeWidget('action_flydown');
foreach ($this->action_items as $item) {
if ($item->visible) {
if ($item instanceof SwatActionItemDivider) {
$flydown->addDivider();
} else {
$flydown->addOption($item->id, $item->title);
}
}
}
// set the flydown back to its initial state (no persistence). The
// flydown is never reset if there is a selected item and the selected
// items has a widget with one or more messages.
if (
$this->auto_reset &&
($this->selected === null ||
$this->selected->widget === null ||
!$this->selected->widget->hasMessage())
) {
$flydown->reset();
}
// select the current action item based upon the flydown value
if (isset($this->action_items_by_id[$flydown->value])) {
$this->selected = $this->action_items_by_id[$flydown->value];
} else {
$this->selected = null;
}
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
echo '<div class="swat-actions-controls">';
$label = new SwatHtmlTag('label');
$label->for = $flydown->getFocusableHtmlId();
$label->setContent(Swat::_('Action: '));
$label->display();
$flydown->display();
echo ' ';
$this->displayButton();
echo '</div>';
foreach ($this->action_items as $item) {
if ($item->widget !== null) {
$div = new SwatHtmlTag('div');
$div->class =
$item == $this->selected ? 'swat-visible' : 'swat-hidden';
$div->id = $this->id . '_' . $item->id;
$div->open();
$item->display();
$div->close();
}
}
echo '<div class="swat-actions-note">';
echo Swat::_('Actions apply to checked items.');
echo '</div>';
$div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"$",
"flydown",
"=",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'action_flydown'",... | Displays this list of actions
Internal widgets are automatically created if they do not exist.
Javascript is displayed, then the display methods of the internal
widgets are called. | [
"Displays",
"this",
"list",
"of",
"actions"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L129-L207 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.process | public function process()
{
parent::process();
$flydown = $this->getCompositeWidget('action_flydown');
$selected_id = $flydown->value;
if (isset($this->action_items_by_id[$selected_id])) {
$this->selected = $this->action_items_by_id[$selected_id];
if ($this->selected->widget !== null) {
$this->selected->widget->process();
}
} else {
$this->selected = null;
}
} | php | public function process()
{
parent::process();
$flydown = $this->getCompositeWidget('action_flydown');
$selected_id = $flydown->value;
if (isset($this->action_items_by_id[$selected_id])) {
$this->selected = $this->action_items_by_id[$selected_id];
if ($this->selected->widget !== null) {
$this->selected->widget->process();
}
} else {
$this->selected = null;
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"$",
"flydown",
"=",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'action_flydown'",
")",
";",
"$",
"selected_id",
"=",
"$",
"flydown",
"->",
"value",
";",
"if",
... | Figures out what action item is selected
This method creates internal widgets if they do not exist, and then
determines what SwatActionItem was selected by the user by calling
the process methods of the internal widgets. | [
"Figures",
"out",
"what",
"action",
"item",
"is",
"selected"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L219-L235 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.addActionItem | public function addActionItem(SwatActionItem $item)
{
$this->action_items[] = $item;
$item->parent = $this;
if ($item->id !== null) {
$this->action_items_by_id[$item->id] = $item;
}
} | php | public function addActionItem(SwatActionItem $item)
{
$this->action_items[] = $item;
$item->parent = $this;
if ($item->id !== null) {
$this->action_items_by_id[$item->id] = $item;
}
} | [
"public",
"function",
"addActionItem",
"(",
"SwatActionItem",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"action_items",
"[",
"]",
"=",
"$",
"item",
";",
"$",
"item",
"->",
"parent",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"item",
"->",
"id",
"!==",
... | Adds an action item
Adds a SwatActionItem to this SwatActions widget.
@param SwatActionItem $item a reference to the item to add.
@see SwatActionItem | [
"Adds",
"an",
"action",
"item"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L249-L257 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.getHtmlHeadEntrySet | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
foreach ($this->action_items as $child_widget) {
$set->addEntrySet($child_widget->getHtmlHeadEntrySet());
}
return $set;
} | php | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
foreach ($this->action_items as $child_widget) {
$set->addEntrySet($child_widget->getHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getHtmlHeadEntrySet",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"action_items",
"as",
"$",
"child_widget",
")",
"{",
"$",
"set",
"->",
"addEntrySet",
"(",... | Gets the SwatHtmlHeadEntry objects needed by this actions list
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by
this actions list.
@see SwatWidget::getHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"needed",
"by",
"this",
"actions",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L302-L311 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.getAvailableHtmlHeadEntrySet | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
foreach ($this->action_items as $child_widget) {
$set->addEntrySet($child_widget->getAvailableHtmlHeadEntrySet());
}
return $set;
} | php | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
foreach ($this->action_items as $child_widget) {
$set->addEntrySet($child_widget->getAvailableHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getAvailableHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getAvailableHtmlHeadEntrySet",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"action_items",
"as",
"$",
"child_widget",
")",
"{",
"$",
"set",
"->",
"ad... | Gets the SwatHtmlHeadEntry objects that may be needed by this actions
list
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be
needed by this actions list.
@see SwatWidget::getAvailableHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"that",
"may",
"be",
"needed",
"by",
"this",
"actions",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L325-L334 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.setViewSelector | public function setViewSelector(
SwatView $view,
SwatViewSelector $selector = null
) {
if ($view === null) {
$selector = null;
} else {
if ($selector === null) {
$selector = $view->getFirstDescendant('SwatViewSelector');
}
if ($selector === null) {
throw new SwatException(
'No selector was specified and view does not have a ' .
'selector'
);
}
}
$this->view = $view;
$this->selector = $selector;
} | php | public function setViewSelector(
SwatView $view,
SwatViewSelector $selector = null
) {
if ($view === null) {
$selector = null;
} else {
if ($selector === null) {
$selector = $view->getFirstDescendant('SwatViewSelector');
}
if ($selector === null) {
throw new SwatException(
'No selector was specified and view does not have a ' .
'selector'
);
}
}
$this->view = $view;
$this->selector = $selector;
} | [
"public",
"function",
"setViewSelector",
"(",
"SwatView",
"$",
"view",
",",
"SwatViewSelector",
"$",
"selector",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"view",
"===",
"null",
")",
"{",
"$",
"selector",
"=",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"... | Sets the optional view and selector of this actions control
If a view and selector are specified for this actions control,
submitting the form is prevented until one or more items in the view
are selected by the selector.
@param SwatView $view the view items must be selected in. Specify null
to remove any existing view selector.
@param SwatViewSelector $selector optional. The selector in the view
that must select the items. If not
specified, the first selector in the
view is used.
@throws SwatException if no selector is specified and the the specified
view does not have a selector. | [
"Sets",
"the",
"optional",
"view",
"and",
"selector",
"of",
"this",
"actions",
"control"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L503-L524 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.createCompositeWidgets | protected function createCompositeWidgets()
{
$flydown = new SwatFlydown($this->id . '_action_flydown');
$flydown->show_blank = $this->show_blank;
$this->addCompositeWidget($flydown, 'action_flydown');
$button = new SwatButton($this->id . '_apply_button');
$this->addCompositeWidget($button, 'apply_button');
} | php | protected function createCompositeWidgets()
{
$flydown = new SwatFlydown($this->id . '_action_flydown');
$flydown->show_blank = $this->show_blank;
$this->addCompositeWidget($flydown, 'action_flydown');
$button = new SwatButton($this->id . '_apply_button');
$this->addCompositeWidget($button, 'apply_button');
} | [
"protected",
"function",
"createCompositeWidgets",
"(",
")",
"{",
"$",
"flydown",
"=",
"new",
"SwatFlydown",
"(",
"$",
"this",
"->",
"id",
".",
"'_action_flydown'",
")",
";",
"$",
"flydown",
"->",
"show_blank",
"=",
"$",
"this",
"->",
"show_blank",
";",
"$... | Creates and the composite flydown and button widgets of this actions
control | [
"Creates",
"and",
"the",
"composite",
"flydown",
"and",
"button",
"widgets",
"of",
"this",
"actions",
"control"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L607-L616 | train |
silverorange/swat | Swat/SwatActions.php | SwatActions.getInlineJavaScript | protected function getInlineJavaScript()
{
static $shown = false;
if (!$shown) {
$javascript = $this->getInlineJavaScriptTranslations();
$shown = true;
} else {
$javascript = '';
}
$values = array();
if ($this->show_blank) {
$values[] = "''";
}
foreach ($this->action_items as $item) {
if ($item->visible) {
$values[] = SwatString::quoteJavaScriptString($item->id);
}
}
$selected_value =
$this->selected === null
? 'null'
: SwatString::quoteJavaScriptString($this->selected->id);
$javascript .= sprintf(
"var %s_obj = new SwatActions(%s, [%s], %s);",
$this->id,
SwatString::quoteJavaScriptString($this->id),
implode(', ', $values),
$selected_value
);
if ($this->view !== null && $this->selector !== null) {
$javascript .= sprintf(
"\n%s_obj.setViewSelector(%s, '%s');",
$this->id,
$this->view->id,
$this->selector->getId()
);
}
return $javascript;
} | php | protected function getInlineJavaScript()
{
static $shown = false;
if (!$shown) {
$javascript = $this->getInlineJavaScriptTranslations();
$shown = true;
} else {
$javascript = '';
}
$values = array();
if ($this->show_blank) {
$values[] = "''";
}
foreach ($this->action_items as $item) {
if ($item->visible) {
$values[] = SwatString::quoteJavaScriptString($item->id);
}
}
$selected_value =
$this->selected === null
? 'null'
: SwatString::quoteJavaScriptString($this->selected->id);
$javascript .= sprintf(
"var %s_obj = new SwatActions(%s, [%s], %s);",
$this->id,
SwatString::quoteJavaScriptString($this->id),
implode(', ', $values),
$selected_value
);
if ($this->view !== null && $this->selector !== null) {
$javascript .= sprintf(
"\n%s_obj.setViewSelector(%s, '%s');",
$this->id,
$this->view->id,
$this->selector->getId()
);
}
return $javascript;
} | [
"protected",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"static",
"$",
"shown",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"shown",
")",
"{",
"$",
"javascript",
"=",
"$",
"this",
"->",
"getInlineJavaScriptTranslations",
"(",
")",
";",
"$",
"shown",
"... | Gets inline JavaScript required to show and hide selected action items
@return string inline JavaScript required to show and hide selected
action items. | [
"Gets",
"inline",
"JavaScript",
"required",
"to",
"show",
"and",
"hide",
"selected",
"action",
"items"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActions.php#L627-L672 | train |
spiral/dumper | src/Dumper.php | Dumper.dump | public function dump($value, int $target = self::OUTPUT): ?string
{
$r = $this->getRenderer($target);
$dump = $r->wrapContent($this->renderValue($r, $value));
switch ($target) {
case self::OUTPUT:
echo $dump;
break;
case self::RETURN:
return $dump;
case self::LOGGER:
if ($this->logger == null) {
throw new DumperException("Unable to dump value to log, no associated LoggerInterface");
}
$this->logger->debug($dump);
break;
case self::ERROR_LOG:
error_log($dump, 0);
break;
}
return null;
} | php | public function dump($value, int $target = self::OUTPUT): ?string
{
$r = $this->getRenderer($target);
$dump = $r->wrapContent($this->renderValue($r, $value));
switch ($target) {
case self::OUTPUT:
echo $dump;
break;
case self::RETURN:
return $dump;
case self::LOGGER:
if ($this->logger == null) {
throw new DumperException("Unable to dump value to log, no associated LoggerInterface");
}
$this->logger->debug($dump);
break;
case self::ERROR_LOG:
error_log($dump, 0);
break;
}
return null;
} | [
"public",
"function",
"dump",
"(",
"$",
"value",
",",
"int",
"$",
"target",
"=",
"self",
"::",
"OUTPUT",
")",
":",
"?",
"string",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"getRenderer",
"(",
"$",
"target",
")",
";",
"$",
"dump",
"=",
"$",
"r",
"-... | Dump given value into target output.
@param mixed $value
@param int $target Possible options: OUTPUT, RETURN, ERROR_LOG, LOGGER.
@return string
@throws DumperException | [
"Dump",
"given",
"value",
"into",
"target",
"output",
"."
] | 87bc579b0ecd69754197804b1fc5e0d5b3293bd3 | https://github.com/spiral/dumper/blob/87bc579b0ecd69754197804b1fc5e0d5b3293bd3/src/Dumper.php#L82-L108 | train |
spiral/dumper | src/Dumper.php | Dumper.setRenderer | public function setRenderer(int $target, RendererInterface $renderer): Dumper
{
if (!isset($this->targets[$target])) {
throw new DumperException(sprintf("Undefined dump target %d", $target));
}
$this->targets[$target] = $renderer;
return $this;
} | php | public function setRenderer(int $target, RendererInterface $renderer): Dumper
{
if (!isset($this->targets[$target])) {
throw new DumperException(sprintf("Undefined dump target %d", $target));
}
$this->targets[$target] = $renderer;
return $this;
} | [
"public",
"function",
"setRenderer",
"(",
"int",
"$",
"target",
",",
"RendererInterface",
"$",
"renderer",
")",
":",
"Dumper",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"targets",
"[",
"$",
"target",
"]",
")",
")",
"{",
"throw",
"new",
"D... | Associate rendered with given output target.
@param int $target
@param RendererInterface $renderer
@return Dumper
@throws DumperException | [
"Associate",
"rendered",
"with",
"given",
"output",
"target",
"."
] | 87bc579b0ecd69754197804b1fc5e0d5b3293bd3 | https://github.com/spiral/dumper/blob/87bc579b0ecd69754197804b1fc5e0d5b3293bd3/src/Dumper.php#L118-L127 | train |
spiral/dumper | src/Dumper.php | Dumper.getRenderer | private function getRenderer(int $target): RendererInterface
{
if ($target == self::OUTPUT && System::isCLI()) {
if (System::isColorsSupported(STDOUT)) {
$target = self::OUTPUT_CLI_COLORS;
} else {
$target = self::OUTPUT_CLI;
}
}
if (!isset($this->targets[$target])) {
throw new DumperException(sprintf("Undefined dump target %d", $target));
}
if (is_string($this->targets[$target])) {
$this->targets[$target] = new $this->targets[$target]();
}
return $this->targets[$target];
} | php | private function getRenderer(int $target): RendererInterface
{
if ($target == self::OUTPUT && System::isCLI()) {
if (System::isColorsSupported(STDOUT)) {
$target = self::OUTPUT_CLI_COLORS;
} else {
$target = self::OUTPUT_CLI;
}
}
if (!isset($this->targets[$target])) {
throw new DumperException(sprintf("Undefined dump target %d", $target));
}
if (is_string($this->targets[$target])) {
$this->targets[$target] = new $this->targets[$target]();
}
return $this->targets[$target];
} | [
"private",
"function",
"getRenderer",
"(",
"int",
"$",
"target",
")",
":",
"RendererInterface",
"{",
"if",
"(",
"$",
"target",
"==",
"self",
"::",
"OUTPUT",
"&&",
"System",
"::",
"isCLI",
"(",
")",
")",
"{",
"if",
"(",
"System",
"::",
"isColorsSupported"... | Returns renderer instance associated with given output target. Automatically detects CLI mode, RR mode and
colorization support.
@param int $target
@return RendererInterface
@throws DumperException | [
"Returns",
"renderer",
"instance",
"associated",
"with",
"given",
"output",
"target",
".",
"Automatically",
"detects",
"CLI",
"mode",
"RR",
"mode",
"and",
"colorization",
"support",
"."
] | 87bc579b0ecd69754197804b1fc5e0d5b3293bd3 | https://github.com/spiral/dumper/blob/87bc579b0ecd69754197804b1fc5e0d5b3293bd3/src/Dumper.php#L137-L156 | train |
honey-comb/core | src/Repositories/Acl/HCPermissionRepository.php | HCPermissionRepository.deletePermission | public function deletePermission(string $action): void
{
/** @var HCAclPermission $permission */
$permission = $this->findOneBy(['action' => $action]);
$permission->roles()->detach();
$permission->forceDelete();
} | php | public function deletePermission(string $action): void
{
/** @var HCAclPermission $permission */
$permission = $this->findOneBy(['action' => $action]);
$permission->roles()->detach();
$permission->forceDelete();
} | [
"public",
"function",
"deletePermission",
"(",
"string",
"$",
"action",
")",
":",
"void",
"{",
"/** @var HCAclPermission $permission */",
"$",
"permission",
"=",
"$",
"this",
"->",
"findOneBy",
"(",
"[",
"'action'",
"=>",
"$",
"action",
"]",
")",
";",
"$",
"... | Deleting permission with and remove it from role_permission connection
@param string $action
@throws \Exception | [
"Deleting",
"permission",
"with",
"and",
"remove",
"it",
"from",
"role_permission",
"connection"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Repositories/Acl/HCPermissionRepository.php#L58-L66 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.createTable | public function createTable($tableName, $tableConfig = null)
{
if ($this->hasTable($tableName)) {
throw new RuntimeException("Table with name {$tableName} is exist. Use rewriteTable()");
}
return $this->create($tableName, $tableConfig);
} | php | public function createTable($tableName, $tableConfig = null)
{
if ($this->hasTable($tableName)) {
throw new RuntimeException("Table with name {$tableName} is exist. Use rewriteTable()");
}
return $this->create($tableName, $tableConfig);
} | [
"public",
"function",
"createTable",
"(",
"$",
"tableName",
",",
"$",
"tableConfig",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasTable",
"(",
"$",
"tableName",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Table with name {$tableNam... | Preparing method of creating table
Checks if the table exists and than if one don't creates the new table
@param string $tableName
@param string $tableConfig
@return mixed
@throws RuntimeException
@throws Exception | [
"Preparing",
"method",
"of",
"creating",
"table"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L244-L251 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.rewriteTable | public function rewriteTable($tableName, $tableConfig = null)
{
if ($this->hasTable($tableName)) {
$this->deleteTable($tableName);
}
return $this->create($tableName, $tableConfig);
} | php | public function rewriteTable($tableName, $tableConfig = null)
{
if ($this->hasTable($tableName)) {
$this->deleteTable($tableName);
}
return $this->create($tableName, $tableConfig);
} | [
"public",
"function",
"rewriteTable",
"(",
"$",
"tableName",
",",
"$",
"tableConfig",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasTable",
"(",
"$",
"tableName",
")",
")",
"{",
"$",
"this",
"->",
"deleteTable",
"(",
"$",
"tableName",
")",
... | Rewrites the table.
Rewrite == delete existing table + create the new table
@param string $tableName
@param string $tableConfig
@return mixed | [
"Rewrites",
"the",
"table",
"."
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L262-L269 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.getTableInfoStr | public function getTableInfoStr($tableName)
{
$metadata = Factory::createSourceFromAdapter($this->db);
$table = $metadata->getTable($tableName);
$spaces = function ($count) {
return str_repeat(' ', $count);
};
$result = "{$spaces(4)}With columns:" . PHP_EOL;
/** @var ColumnObject $column */
foreach ($table->getColumns() as $column) {
$result .= "{$spaces(8)}{$column->getName()} -> {$column->getDataType()}" . PHP_EOL;
}
$result .= PHP_EOL;
$result .= "{$spaces(4)}With constraints:" . PHP_EOL;
/** @var ConstraintObject $constraint */
foreach ($metadata->getConstraints($tableName) as $constraint) {
$result .= "{$spaces(8)}{$constraint->getName()} -> {$constraint->getType()}" . PHP_EOL;
if (!$constraint->hasColumns()) {
continue;
}
$result .= "{$spaces(12)}column: " . implode(', ', $constraint->getColumns());
if ($constraint->isForeignKey()) {
$foreignKeyColumns = [];
foreach ($constraint->getReferencedColumns() as $referenceColumn) {
$foreignKeyColumns[] = "{$constraint->getReferencedTableName()}.{$referenceColumn}";
}
$result .= ' => ' . implode(', ', $foreignKeyColumns) . PHP_EOL;
$result .= "{$spaces(12)}OnDeleteRule: {$constraint->getDeleteRule()}" . PHP_EOL;
$result .= "{$spaces(12)}OnUpdateRule: {$constraint->getUpdateRule()}" . PHP_EOL;
} else {
$result .= PHP_EOL;
}
}
return $result;
} | php | public function getTableInfoStr($tableName)
{
$metadata = Factory::createSourceFromAdapter($this->db);
$table = $metadata->getTable($tableName);
$spaces = function ($count) {
return str_repeat(' ', $count);
};
$result = "{$spaces(4)}With columns:" . PHP_EOL;
/** @var ColumnObject $column */
foreach ($table->getColumns() as $column) {
$result .= "{$spaces(8)}{$column->getName()} -> {$column->getDataType()}" . PHP_EOL;
}
$result .= PHP_EOL;
$result .= "{$spaces(4)}With constraints:" . PHP_EOL;
/** @var ConstraintObject $constraint */
foreach ($metadata->getConstraints($tableName) as $constraint) {
$result .= "{$spaces(8)}{$constraint->getName()} -> {$constraint->getType()}" . PHP_EOL;
if (!$constraint->hasColumns()) {
continue;
}
$result .= "{$spaces(12)}column: " . implode(', ', $constraint->getColumns());
if ($constraint->isForeignKey()) {
$foreignKeyColumns = [];
foreach ($constraint->getReferencedColumns() as $referenceColumn) {
$foreignKeyColumns[] = "{$constraint->getReferencedTableName()}.{$referenceColumn}";
}
$result .= ' => ' . implode(', ', $foreignKeyColumns) . PHP_EOL;
$result .= "{$spaces(12)}OnDeleteRule: {$constraint->getDeleteRule()}" . PHP_EOL;
$result .= "{$spaces(12)}OnUpdateRule: {$constraint->getUpdateRule()}" . PHP_EOL;
} else {
$result .= PHP_EOL;
}
}
return $result;
} | [
"public",
"function",
"getTableInfoStr",
"(",
"$",
"tableName",
")",
"{",
"$",
"metadata",
"=",
"Factory",
"::",
"createSourceFromAdapter",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"table",
"=",
"$",
"metadata",
"->",
"getTable",
"(",
"$",
"tableName",... | Builds and gets table info
@see http://framework.zend.com/manual/current/en/modules/zend.db.metadata.html
@param string $tableName
@return string | [
"Builds",
"and",
"gets",
"table",
"info"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L292-L336 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.getTableConfig | public function getTableConfig($tableConfig)
{
if (is_string($tableConfig)) {
$config = $this->getConfig();
if (isset($config[self::KEY_TABLES_CONFIGS][$tableConfig])) {
$tableConfig = $config[self::KEY_TABLES_CONFIGS][$tableConfig];
} else {
throw new InvalidArgumentException("Unknown table '{$tableConfig}' in config");
}
}
return $tableConfig;
} | php | public function getTableConfig($tableConfig)
{
if (is_string($tableConfig)) {
$config = $this->getConfig();
if (isset($config[self::KEY_TABLES_CONFIGS][$tableConfig])) {
$tableConfig = $config[self::KEY_TABLES_CONFIGS][$tableConfig];
} else {
throw new InvalidArgumentException("Unknown table '{$tableConfig}' in config");
}
}
return $tableConfig;
} | [
"public",
"function",
"getTableConfig",
"(",
"$",
"tableConfig",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"tableConfig",
")",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",... | Fetches the table config from common config of all the tables
@param $tableConfig
@return mixed
@throws Exception | [
"Fetches",
"the",
"table",
"config",
"from",
"common",
"config",
"of",
"all",
"the",
"tables"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L383-L396 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.create | protected function create($tableName, $tableConfig = null)
{
$tableConfig = is_null($tableConfig) ? $tableConfig = $tableName : $tableConfig;
$createTable = $this->createCreateTable($tableName, $this->getTableConfig($tableConfig));
$sql = $this->getCreateTableSql($createTable, $tableName);
return $this->db->query($sql, Adapter\Adapter::QUERY_MODE_EXECUTE);
} | php | protected function create($tableName, $tableConfig = null)
{
$tableConfig = is_null($tableConfig) ? $tableConfig = $tableName : $tableConfig;
$createTable = $this->createCreateTable($tableName, $this->getTableConfig($tableConfig));
$sql = $this->getCreateTableSql($createTable, $tableName);
return $this->db->query($sql, Adapter\Adapter::QUERY_MODE_EXECUTE);
} | [
"protected",
"function",
"create",
"(",
"$",
"tableName",
",",
"$",
"tableConfig",
"=",
"null",
")",
"{",
"$",
"tableConfig",
"=",
"is_null",
"(",
"$",
"tableConfig",
")",
"?",
"$",
"tableConfig",
"=",
"$",
"tableName",
":",
"$",
"tableConfig",
";",
"$",... | Creates table by its name and config
@param $tableName
@param $tableConfig
@return Adapter\Driver\StatementInterface|\Zend\Db\ResultSet\ResultSet
@throws Exception | [
"Creates",
"table",
"by",
"its",
"name",
"and",
"config"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L406-L413 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.createCreateTable | protected function createCreateTable(string $tableName, array $tableConfig): CreateTable
{
$createTable = new CreateTable($tableName);
$primaryKeys = [];
foreach ($tableConfig as $fieldName => $fieldData) {
if (isset($fieldData[static::PRIMARY_KEY])) {
$primaryKeys[] = $fieldName;
}
$column = $this->createColumn($fieldData, $fieldName);
$createTable->addColumn($column);
if (isset($fieldData[self::UNIQUE_KEY])) {
$constrain = $this->createUniqueKeyConstraint($fieldData[self::UNIQUE_KEY], $fieldName, $tableName);
$createTable->addConstraint($constrain);
}
if (isset($fieldData[self::FOREIGN_KEY])) {
$constrain = $this->createForeignKeyConstraint($fieldData[self::FOREIGN_KEY], $fieldName, $tableName);
$createTable->addConstraint($constrain);
}
}
if (count($primaryKeys)) {
$createTable->addConstraint(new Constraint\PrimaryKey(...$primaryKeys));
} else {
$createTable->addConstraint(new Constraint\PrimaryKey('id'));
}
return $createTable;
} | php | protected function createCreateTable(string $tableName, array $tableConfig): CreateTable
{
$createTable = new CreateTable($tableName);
$primaryKeys = [];
foreach ($tableConfig as $fieldName => $fieldData) {
if (isset($fieldData[static::PRIMARY_KEY])) {
$primaryKeys[] = $fieldName;
}
$column = $this->createColumn($fieldData, $fieldName);
$createTable->addColumn($column);
if (isset($fieldData[self::UNIQUE_KEY])) {
$constrain = $this->createUniqueKeyConstraint($fieldData[self::UNIQUE_KEY], $fieldName, $tableName);
$createTable->addConstraint($constrain);
}
if (isset($fieldData[self::FOREIGN_KEY])) {
$constrain = $this->createForeignKeyConstraint($fieldData[self::FOREIGN_KEY], $fieldName, $tableName);
$createTable->addConstraint($constrain);
}
}
if (count($primaryKeys)) {
$createTable->addConstraint(new Constraint\PrimaryKey(...$primaryKeys));
} else {
$createTable->addConstraint(new Constraint\PrimaryKey('id'));
}
return $createTable;
} | [
"protected",
"function",
"createCreateTable",
"(",
"string",
"$",
"tableName",
",",
"array",
"$",
"tableConfig",
")",
":",
"CreateTable",
"{",
"$",
"createTable",
"=",
"new",
"CreateTable",
"(",
"$",
"tableName",
")",
";",
"$",
"primaryKeys",
"=",
"[",
"]",
... | Create and return instance of CreateTable
@param $tableName
@param $tableConfig
@return CreateTable | [
"Create",
"and",
"return",
"instance",
"of",
"CreateTable"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L422-L453 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.createColumn | protected function createColumn(array $fieldData, string $fieldName): ColumnInterface
{
$fieldType = $fieldData[self::FIELD_TYPE];
switch (true) {
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_SIMPLE]):
$defaultFieldParameters = $this->parameters[self::COLUMN_SIMPLE];
$columnClass = $this->fieldClasses[self::COLUMN_SIMPLE][$fieldType];
break;
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_LENGTH]):
$defaultFieldParameters = $this->parameters[self::COLUMN_LENGTH];
$columnClass = $this->fieldClasses[self::COLUMN_LENGTH][$fieldType];
break;
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_PRECISION]):
$defaultFieldParameters = $this->parameters[self::COLUMN_PRECISION];
$columnClass = $this->fieldClasses[self::COLUMN_PRECISION][$fieldType];
break;
default:
throw new InvalidArgumentException("Unknown field type: {$fieldType}");
}
$args = [];
foreach ($defaultFieldParameters as $key => $value) {
if ($key === self::PROPERTY_OPTIONS
&& isset($fieldData[self::FIELD_PARAMS][self::PROPERTY_OPTIONS])
&& key_exists(self::OPTION_AUTOINCREMENT, $fieldData[self::FIELD_PARAMS][self::PROPERTY_OPTIONS])) {
trigger_error("Autoincrement field is deprecated", E_USER_DEPRECATED);
}
if (isset($fieldData[self::FIELD_PARAMS]) && key_exists($key, $fieldData[self::FIELD_PARAMS])) {
$args[] = $fieldData[self::FIELD_PARAMS][$key];
} else {
$args[] = $value;
}
}
array_unshift($args, $fieldName);
return new $columnClass(...$args);
} | php | protected function createColumn(array $fieldData, string $fieldName): ColumnInterface
{
$fieldType = $fieldData[self::FIELD_TYPE];
switch (true) {
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_SIMPLE]):
$defaultFieldParameters = $this->parameters[self::COLUMN_SIMPLE];
$columnClass = $this->fieldClasses[self::COLUMN_SIMPLE][$fieldType];
break;
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_LENGTH]):
$defaultFieldParameters = $this->parameters[self::COLUMN_LENGTH];
$columnClass = $this->fieldClasses[self::COLUMN_LENGTH][$fieldType];
break;
case key_exists($fieldType, $this->fieldClasses[self::COLUMN_PRECISION]):
$defaultFieldParameters = $this->parameters[self::COLUMN_PRECISION];
$columnClass = $this->fieldClasses[self::COLUMN_PRECISION][$fieldType];
break;
default:
throw new InvalidArgumentException("Unknown field type: {$fieldType}");
}
$args = [];
foreach ($defaultFieldParameters as $key => $value) {
if ($key === self::PROPERTY_OPTIONS
&& isset($fieldData[self::FIELD_PARAMS][self::PROPERTY_OPTIONS])
&& key_exists(self::OPTION_AUTOINCREMENT, $fieldData[self::FIELD_PARAMS][self::PROPERTY_OPTIONS])) {
trigger_error("Autoincrement field is deprecated", E_USER_DEPRECATED);
}
if (isset($fieldData[self::FIELD_PARAMS]) && key_exists($key, $fieldData[self::FIELD_PARAMS])) {
$args[] = $fieldData[self::FIELD_PARAMS][$key];
} else {
$args[] = $value;
}
}
array_unshift($args, $fieldName);
return new $columnClass(...$args);
} | [
"protected",
"function",
"createColumn",
"(",
"array",
"$",
"fieldData",
",",
"string",
"$",
"fieldName",
")",
":",
"ColumnInterface",
"{",
"$",
"fieldType",
"=",
"$",
"fieldData",
"[",
"self",
"::",
"FIELD_TYPE",
"]",
";",
"switch",
"(",
"true",
")",
"{",... | Create and return instance of ColumnInterface
@param array $fieldData
@param string $fieldName
@return ColumnInterface | [
"Create",
"and",
"return",
"instance",
"of",
"ColumnInterface"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L480-L520 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.createUniqueKeyConstraint | protected function createUniqueKeyConstraint(
$constraintOptions,
string $fieldName,
string $tableName
): Constraint\UniqueKey {
$constraintName = is_string($constraintOptions) ? $constraintOptions : "UniqueKey_{$tableName}_{$fieldName}";
return new Constraint\UniqueKey([$fieldName], $constraintName);
} | php | protected function createUniqueKeyConstraint(
$constraintOptions,
string $fieldName,
string $tableName
): Constraint\UniqueKey {
$constraintName = is_string($constraintOptions) ? $constraintOptions : "UniqueKey_{$tableName}_{$fieldName}";
return new Constraint\UniqueKey([$fieldName], $constraintName);
} | [
"protected",
"function",
"createUniqueKeyConstraint",
"(",
"$",
"constraintOptions",
",",
"string",
"$",
"fieldName",
",",
"string",
"$",
"tableName",
")",
":",
"Constraint",
"\\",
"UniqueKey",
"{",
"$",
"constraintName",
"=",
"is_string",
"(",
"$",
"constraintOpt... | Create and return instance of Constraint\UniqueKey
@param null $constraintOptions
@param string $fieldName
@param string $tableName
@return Constraint\UniqueKey | [
"Create",
"and",
"return",
"instance",
"of",
"Constraint",
"\\",
"UniqueKey"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L530-L538 | train |
rollun-com/rollun-datastore | src/DataStore/src/TableGateway/TableManagerMysql.php | TableManagerMysql.createForeignKeyConstraint | protected function createForeignKeyConstraint(array $constraintOptions, string $fieldName, string $tableName)
{
if (is_string($constraintOptions['name'] ?? null)) {
$constraintName = $constraintOptions;
} else {
$constraintName = "ForeignKey_{$tableName}_{$fieldName}";
}
if (empty($constraintOptions['referenceTable'])) {
throw new InvalidArgumentException("Missing option 'referenceTable' for foreign key constraint");
}
if (empty($constraintOptions['referenceColumn'])) {
throw new InvalidArgumentException("Missing option 'referenceColumn' for foreign key constraint");
}
return new Constraint\ForeignKey(
$constraintName,
[$fieldName],
$constraintOptions['referenceTable'],
$constraintOptions['referenceColumn'],
$constraintOptions['onDeleteRule'] ?? null,
$constraintOptions['onUpdateRule'] ?? null
);
} | php | protected function createForeignKeyConstraint(array $constraintOptions, string $fieldName, string $tableName)
{
if (is_string($constraintOptions['name'] ?? null)) {
$constraintName = $constraintOptions;
} else {
$constraintName = "ForeignKey_{$tableName}_{$fieldName}";
}
if (empty($constraintOptions['referenceTable'])) {
throw new InvalidArgumentException("Missing option 'referenceTable' for foreign key constraint");
}
if (empty($constraintOptions['referenceColumn'])) {
throw new InvalidArgumentException("Missing option 'referenceColumn' for foreign key constraint");
}
return new Constraint\ForeignKey(
$constraintName,
[$fieldName],
$constraintOptions['referenceTable'],
$constraintOptions['referenceColumn'],
$constraintOptions['onDeleteRule'] ?? null,
$constraintOptions['onUpdateRule'] ?? null
);
} | [
"protected",
"function",
"createForeignKeyConstraint",
"(",
"array",
"$",
"constraintOptions",
",",
"string",
"$",
"fieldName",
",",
"string",
"$",
"tableName",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"constraintOptions",
"[",
"'name'",
"]",
"??",
"null",
... | Create and return instance of Constraint\ForeignKey
@param array $constraintOptions
@param string $fieldName
@param string $tableName
@return Constraint\ForeignKey | [
"Create",
"and",
"return",
"instance",
"of",
"Constraint",
"\\",
"ForeignKey"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/TableGateway/TableManagerMysql.php#L548-L572 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.getResultsMessage | public function getResultsMessage($unit = null, $unit_plural = null)
{
if ($unit === null) {
$unit = Swat::_('record');
}
if ($unit_plural === null) {
$unit_plural = Swat::_('records');
}
$message = '';
if ($this->total_records === 0) {
$message = sprintf(Swat::_('No %s.'), $unit_plural);
} elseif ($this->total_records === 1) {
$message = sprintf(Swat::_('One %s.'), $unit);
} else {
$locale = SwatI18NLocale::get();
$message = sprintf(
Swat::_('%s %s, displaying %s to %s'),
$locale->formatNumber($this->total_records),
$unit_plural,
$locale->formatNumber($this->current_record + 1),
$locale->formatNumber(
min(
$this->current_record + $this->page_size,
$this->total_records
)
)
);
}
return $message;
} | php | public function getResultsMessage($unit = null, $unit_plural = null)
{
if ($unit === null) {
$unit = Swat::_('record');
}
if ($unit_plural === null) {
$unit_plural = Swat::_('records');
}
$message = '';
if ($this->total_records === 0) {
$message = sprintf(Swat::_('No %s.'), $unit_plural);
} elseif ($this->total_records === 1) {
$message = sprintf(Swat::_('One %s.'), $unit);
} else {
$locale = SwatI18NLocale::get();
$message = sprintf(
Swat::_('%s %s, displaying %s to %s'),
$locale->formatNumber($this->total_records),
$unit_plural,
$locale->formatNumber($this->current_record + 1),
$locale->formatNumber(
min(
$this->current_record + $this->page_size,
$this->total_records
)
)
);
}
return $message;
} | [
"public",
"function",
"getResultsMessage",
"(",
"$",
"unit",
"=",
"null",
",",
"$",
"unit_plural",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"unit",
"===",
"null",
")",
"{",
"$",
"unit",
"=",
"Swat",
"::",
"_",
"(",
"'record'",
")",
";",
"}",
"if",
... | Gets a human readable summary of the current state of this pagination
widget
@param $unit string optional. The type of unit being returned. By
default this is 'record'.
@param $unit_plural string optional. The plural version of the
<i>$unit</i> parameter. By default this is
'records'.
@return string a human readable summary of the current state of this
pagination widget. | [
"Gets",
"a",
"human",
"readable",
"summary",
"of",
"the",
"current",
"state",
"of",
"this",
"pagination",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L188-L221 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$this->calculatePages();
if ($this->total_pages > 1) {
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
if ($this->display_parts & self::POSITION) {
$this->displayPosition();
}
if ($this->display_parts & self::PREV) {
$this->displayPrev();
}
if ($this->display_parts & self::PAGES) {
$this->displayPages();
}
if ($this->display_parts & self::NEXT) {
$this->displayNext();
}
$div_tag->close();
}
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$this->calculatePages();
if ($this->total_pages > 1) {
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
if ($this->display_parts & self::POSITION) {
$this->displayPosition();
}
if ($this->display_parts & self::PREV) {
$this->displayPrev();
}
if ($this->display_parts & self::PAGES) {
$this->displayPages();
}
if ($this->display_parts & self::NEXT) {
$this->displayNext();
}
$div_tag->close();
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"$",
"this",
"->",
"calculatePages",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->"... | Displays this pagination widget | [
"Displays",
"this",
"pagination",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L229-L263 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.setCurrentPage | public function setCurrentPage($page)
{
$this->current_page = max(1, (int) $page);
$this->current_record = ($this->current_page - 1) * $this->page_size;
} | php | public function setCurrentPage($page)
{
$this->current_page = max(1, (int) $page);
$this->current_record = ($this->current_page - 1) * $this->page_size;
} | [
"public",
"function",
"setCurrentPage",
"(",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"current_page",
"=",
"max",
"(",
"1",
",",
"(",
"int",
")",
"$",
"page",
")",
";",
"$",
"this",
"->",
"current_record",
"=",
"(",
"$",
"this",
"->",
"current_page"... | Set the current page that is displayed
Calculates the current_record properties.
@param integer $page The current page being displayed. | [
"Set",
"the",
"current",
"page",
"that",
"is",
"displayed"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L275-L280 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.displayPrev | protected function displayPrev()
{
if ($this->prev_page > 0) {
$link = $this->getLink();
$anchor = new SwatHtmlTag('a');
$anchor->href = sprintf($link, (string) $this->prev_page);
// this is a non-breaking space
$anchor->setContent($this->previous_label);
$anchor->class = 'swat-pagination-nextprev';
$anchor->display();
} else {
$span = new SwatHtmlTag('span');
$span->class = 'swat-pagination-nextprev';
$span->setContent($this->previous_label);
$span->display();
}
} | php | protected function displayPrev()
{
if ($this->prev_page > 0) {
$link = $this->getLink();
$anchor = new SwatHtmlTag('a');
$anchor->href = sprintf($link, (string) $this->prev_page);
// this is a non-breaking space
$anchor->setContent($this->previous_label);
$anchor->class = 'swat-pagination-nextprev';
$anchor->display();
} else {
$span = new SwatHtmlTag('span');
$span->class = 'swat-pagination-nextprev';
$span->setContent($this->previous_label);
$span->display();
}
} | [
"protected",
"function",
"displayPrev",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"prev_page",
">",
"0",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"getLink",
"(",
")",
";",
"$",
"anchor",
"=",
"new",
"SwatHtmlTag",
"(",
"'a'",
")",
";",
"... | Displays the previous page link | [
"Displays",
"the",
"previous",
"page",
"link"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L301-L318 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.displayPosition | protected function displayPosition()
{
$div = new SwatHtmlTag('div');
$div->class = 'swat-pagination-position';
$div->setContent(
sprintf(
Swat::_('Page %d of %d'),
$this->current_page,
$this->total_pages
)
);
$div->display();
} | php | protected function displayPosition()
{
$div = new SwatHtmlTag('div');
$div->class = 'swat-pagination-position';
$div->setContent(
sprintf(
Swat::_('Page %d of %d'),
$this->current_page,
$this->total_pages
)
);
$div->display();
} | [
"protected",
"function",
"displayPosition",
"(",
")",
"{",
"$",
"div",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
"div",
"->",
"class",
"=",
"'swat-pagination-position'",
";",
"$",
"div",
"->",
"setContent",
"(",
"sprintf",
"(",
"Swat",
"::",
... | Displays the current page position
i.e. "1 of 3" | [
"Displays",
"the",
"current",
"page",
"position"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L328-L342 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.displayNext | protected function displayNext()
{
if ($this->next_page > 0) {
$link = $this->getLink();
$anchor = new SwatHtmlTag('a');
$anchor->href = sprintf($link, (string) $this->next_page);
// this is a non-breaking space
$anchor->setContent($this->next_label);
$anchor->class = 'swat-pagination-nextprev';
$anchor->display();
} else {
$span = new SwatHtmlTag('span');
$span->class = 'swat-pagination-nextprev';
// this is a non-breaking space
$span->setContent($this->next_label);
$span->display();
}
} | php | protected function displayNext()
{
if ($this->next_page > 0) {
$link = $this->getLink();
$anchor = new SwatHtmlTag('a');
$anchor->href = sprintf($link, (string) $this->next_page);
// this is a non-breaking space
$anchor->setContent($this->next_label);
$anchor->class = 'swat-pagination-nextprev';
$anchor->display();
} else {
$span = new SwatHtmlTag('span');
$span->class = 'swat-pagination-nextprev';
// this is a non-breaking space
$span->setContent($this->next_label);
$span->display();
}
} | [
"protected",
"function",
"displayNext",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"next_page",
">",
"0",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"getLink",
"(",
")",
";",
"$",
"anchor",
"=",
"new",
"SwatHtmlTag",
"(",
"'a'",
")",
";",
"... | Displays the next page link | [
"Displays",
"the",
"next",
"page",
"link"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L350-L368 | train |
silverorange/swat | Swat/SwatPagination.php | SwatPagination.calculatePages | protected function calculatePages()
{
$this->total_pages = ceil($this->total_records / $this->page_size);
if (
$this->total_pages <= 1 ||
$this->total_pages == $this->current_page
) {
$this->next_page = 0;
} else {
$this->next_page = $this->current_page + 1;
}
if ($this->current_page > 0) {
$this->prev_page = $this->current_page - 1;
} else {
$this->prev_page = 0;
}
} | php | protected function calculatePages()
{
$this->total_pages = ceil($this->total_records / $this->page_size);
if (
$this->total_pages <= 1 ||
$this->total_pages == $this->current_page
) {
$this->next_page = 0;
} else {
$this->next_page = $this->current_page + 1;
}
if ($this->current_page > 0) {
$this->prev_page = $this->current_page - 1;
} else {
$this->prev_page = 0;
}
} | [
"protected",
"function",
"calculatePages",
"(",
")",
"{",
"$",
"this",
"->",
"total_pages",
"=",
"ceil",
"(",
"$",
"this",
"->",
"total_records",
"/",
"$",
"this",
"->",
"page_size",
")",
";",
"if",
"(",
"$",
"this",
"->",
"total_pages",
"<=",
"1",
"||... | Calculates page totals
Sets the internal total_pages, next_page and prev_page properties. | [
"Calculates",
"page",
"totals"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatPagination.php#L469-L487 | train |
TeknooSoftware/states | src/Automated/Assertion/Property/AbstractConstraint.php | AbstractConstraint.isValid | protected function isValid(&$value): ConstraintInterface
{
if ($this->constraintsSet instanceof ConstraintsSetInterface) {
$this->constraintsSet->isValid($value);
}
return $this;
} | php | protected function isValid(&$value): ConstraintInterface
{
if ($this->constraintsSet instanceof ConstraintsSetInterface) {
$this->constraintsSet->isValid($value);
}
return $this;
} | [
"protected",
"function",
"isValid",
"(",
"&",
"$",
"value",
")",
":",
"ConstraintInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"constraintsSet",
"instanceof",
"ConstraintsSetInterface",
")",
"{",
"$",
"this",
"->",
"constraintsSet",
"->",
"isValid",
"(",
"$",... | To return the success of the check to the ConstraintSet and continue the workflow
@param mixed $value
@return ConstraintInterface | [
"To",
"return",
"the",
"success",
"of",
"the",
"check",
"to",
"the",
"ConstraintSet",
"and",
"continue",
"the",
"workflow"
] | 0c675b768781ee3a3a15c2663cffec5d50c1d5fd | https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Automated/Assertion/Property/AbstractConstraint.php#L67-L74 | train |
silverorange/swat | Swat/SwatMessageDisplay.php | SwatMessageDisplay.display | public function display()
{
if (!$this->visible) {
return;
}
if ($this->getMessageCount() === 0) {
return;
}
parent::display();
$wrapper_div = new SwatHtmlTag('div');
$wrapper_div->id = $this->id;
$wrapper_div->class = $this->getCSSClassString();
$wrapper_div->open();
$has_dismiss_link = false;
$message_count = count($this->display_messages);
$count = 1;
foreach ($this->display_messages as $key => $message) {
if (in_array($key, $this->dismissable_messages)) {
$has_dismiss_link = true;
}
$first = $count === 1;
$last = $count === $message_count;
$this->displayMessage($key, $message, $first, $last);
$count++;
}
$wrapper_div->close();
if ($has_dismiss_link) {
Swat::displayInlineJavaScript($this->getInlineJavaScript());
}
} | php | public function display()
{
if (!$this->visible) {
return;
}
if ($this->getMessageCount() === 0) {
return;
}
parent::display();
$wrapper_div = new SwatHtmlTag('div');
$wrapper_div->id = $this->id;
$wrapper_div->class = $this->getCSSClassString();
$wrapper_div->open();
$has_dismiss_link = false;
$message_count = count($this->display_messages);
$count = 1;
foreach ($this->display_messages as $key => $message) {
if (in_array($key, $this->dismissable_messages)) {
$has_dismiss_link = true;
}
$first = $count === 1;
$last = $count === $message_count;
$this->displayMessage($key, $message, $first, $last);
$count++;
}
$wrapper_div->close();
if ($has_dismiss_link) {
Swat::displayInlineJavaScript($this->getInlineJavaScript());
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getMessageCount",
"(",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"disp... | Displays messages in this message display
The CSS class of each message is determined by the message being
displayed. | [
"Displays",
"messages",
"in",
"this",
"message",
"display"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMessageDisplay.php#L153-L193 | train |
silverorange/swat | Swat/SwatMessageDisplay.php | SwatMessageDisplay.displayMessage | protected function displayMessage(
$message_id,
SwatMessage $message,
$first = false,
$last = false
) {
$message_div = new SwatHtmlTag('div');
$container_div = new SwatHtmlTag('div');
$message_div->id = $this->id . '_' . $message_id;
$message_div->class = $message->getCSSClassString();
if ($first) {
$message_div->class .= ' swat-message-first';
}
if ($last) {
$message_div->class .= ' swat-message-last';
}
$message_div->open();
$container_div->class = 'swat-message-container';
$container_div->open();
$primary_content = new SwatHtmlTag('h3');
$primary_content->class = 'swat-message-primary-content';
$primary_content->setContent(
$message->primary_content,
$message->content_type
);
$primary_content->display();
if ($message->secondary_content !== null) {
$secondary_div = new SwatHtmlTag('div');
$secondary_div->class = 'swat-message-secondary-content';
$secondary_div->setContent(
$message->secondary_content,
$message->content_type
);
$secondary_div->display();
}
$container_div->close();
$message_div->close();
} | php | protected function displayMessage(
$message_id,
SwatMessage $message,
$first = false,
$last = false
) {
$message_div = new SwatHtmlTag('div');
$container_div = new SwatHtmlTag('div');
$message_div->id = $this->id . '_' . $message_id;
$message_div->class = $message->getCSSClassString();
if ($first) {
$message_div->class .= ' swat-message-first';
}
if ($last) {
$message_div->class .= ' swat-message-last';
}
$message_div->open();
$container_div->class = 'swat-message-container';
$container_div->open();
$primary_content = new SwatHtmlTag('h3');
$primary_content->class = 'swat-message-primary-content';
$primary_content->setContent(
$message->primary_content,
$message->content_type
);
$primary_content->display();
if ($message->secondary_content !== null) {
$secondary_div = new SwatHtmlTag('div');
$secondary_div->class = 'swat-message-secondary-content';
$secondary_div->setContent(
$message->secondary_content,
$message->content_type
);
$secondary_div->display();
}
$container_div->close();
$message_div->close();
} | [
"protected",
"function",
"displayMessage",
"(",
"$",
"message_id",
",",
"SwatMessage",
"$",
"message",
",",
"$",
"first",
"=",
"false",
",",
"$",
"last",
"=",
"false",
")",
"{",
"$",
"message_div",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
... | Display a single message of this message display
@param integer $message_id a unique identifier for the message within
this message display.
@param SwatMessage $message the message to display.
@param boolean $first optional. Whether or not the message is the first
message in this message display.
@param boolean $last optional. Whether or not the message is the last
message in this message display. | [
"Display",
"a",
"single",
"message",
"of",
"this",
"message",
"display"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMessageDisplay.php#L242-L289 | train |
silverorange/swat | Swat/SwatMessageDisplay.php | SwatMessageDisplay.getInlineJavaScript | protected function getInlineJavaScript()
{
static $shown = false;
if (!$shown) {
$javascript = $this->getInlineJavaScriptTranslations();
$shown = true;
} else {
$javascript = '';
}
$dismissable_messages =
'[' . implode(', ', $this->dismissable_messages) . ']';
$javascript .= sprintf(
"var %s_obj = new %s('%s', %s);",
$this->id,
$this->getJavaScriptClass(),
$this->id,
$dismissable_messages
);
return $javascript;
} | php | protected function getInlineJavaScript()
{
static $shown = false;
if (!$shown) {
$javascript = $this->getInlineJavaScriptTranslations();
$shown = true;
} else {
$javascript = '';
}
$dismissable_messages =
'[' . implode(', ', $this->dismissable_messages) . ']';
$javascript .= sprintf(
"var %s_obj = new %s('%s', %s);",
$this->id,
$this->getJavaScriptClass(),
$this->id,
$dismissable_messages
);
return $javascript;
} | [
"protected",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"static",
"$",
"shown",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"shown",
")",
"{",
"$",
"javascript",
"=",
"$",
"this",
"->",
"getInlineJavaScriptTranslations",
"(",
")",
";",
"$",
"shown",
"... | Gets the inline JavaScript for hiding messages | [
"Gets",
"the",
"inline",
"JavaScript",
"for",
"hiding",
"messages"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMessageDisplay.php#L326-L349 | train |
silverorange/swat | Swat/SwatReplicableFrame.php | SwatReplicableFrame.init | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$frame = new SwatFrame();
$frame->id = $frame->getUniqueId();
$prototype_id = $frame->id;
foreach ($children as $child_widget) {
$frame->add($child_widget);
}
$this->add($frame);
parent::init();
if ($this->replication_ids === null && is_array($this->replicators)) {
foreach ($this->replicators as $id => $title) {
$frame = $this->getWidget($prototype_id, $id);
$frame->title = $title;
}
}
} | php | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$frame = new SwatFrame();
$frame->id = $frame->getUniqueId();
$prototype_id = $frame->id;
foreach ($children as $child_widget) {
$frame->add($child_widget);
}
$this->add($frame);
parent::init();
if ($this->replication_ids === null && is_array($this->replicators)) {
foreach ($this->replicators as $id => $title) {
$frame = $this->getWidget($prototype_id, $id);
$frame->title = $title;
}
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child_widget",
")",
"{",
"$",
"children",
"[",
"]",
"=",
"$",
"this",
"->",
"remove",
"(",
"$",
... | Initilizes this replicable frame | [
"Initilizes",
"this",
"replicable",
"frame"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatReplicableFrame.php#L23-L48 | train |
silverorange/swat | SwatDB/SwatDBClassMap.php | SwatDBClassMap.add | public static function add($from_class_name, $to_class_name)
{
// check for circular dependency
if (array_key_exists($to_class_name, self::$map)) {
$class_name = $to_class_name;
$child_class_names = array($class_name);
while (array_key_exists($class_name, self::$map)) {
$class_name = self::$map[$class_name];
$child_class_names[] = $class_name;
}
if (in_array($from_class_name, $child_class_names)) {
throw new SwatException(
sprintf(
'Circular class dependency detected: %s => %s',
$from_class_name,
implode(' => ', $child_class_names)
)
);
}
}
self::$map[$from_class_name] = $to_class_name;
} | php | public static function add($from_class_name, $to_class_name)
{
// check for circular dependency
if (array_key_exists($to_class_name, self::$map)) {
$class_name = $to_class_name;
$child_class_names = array($class_name);
while (array_key_exists($class_name, self::$map)) {
$class_name = self::$map[$class_name];
$child_class_names[] = $class_name;
}
if (in_array($from_class_name, $child_class_names)) {
throw new SwatException(
sprintf(
'Circular class dependency detected: %s => %s',
$from_class_name,
implode(' => ', $child_class_names)
)
);
}
}
self::$map[$from_class_name] = $to_class_name;
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"from_class_name",
",",
"$",
"to_class_name",
")",
"{",
"// check for circular dependency",
"if",
"(",
"array_key_exists",
"(",
"$",
"to_class_name",
",",
"self",
"::",
"$",
"map",
")",
")",
"{",
"$",
"class_nam... | Maps a class name to another class name
Subsequent calls to {@link SwatDBClassMap::get()} using the
<i>$from_class_name</i> will return the <i>$to_class_name</i>. Class
names may be mapped to already mapped class names. For example:
<code>
SwatDBClassMap::add('Object', 'MyObject');
SwatDBClassMap::add('MyObject', 'MyOtherObject');
echo SwatDBClassMap::get('Object'); // MyOtherObject
</code>
If a circular dependency is created, an exception is thrown. If the
<i>$from_class_name</i> is already mapped to another class the old
mapping is overwritten.
@param string $from_class_name the class name to map from.
@param string $to_class_name the class name to map to. The mapped class
must be a subclass of the
<i>$from_class_name</i> otherwise class
resolution using
{@link SwatDBClassMap::get()} will throw
an exception.
@throws SwatException if the added mapping creates a circular dependency. | [
"Maps",
"a",
"class",
"name",
"to",
"another",
"class",
"name"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBClassMap.php#L68-L91 | train |
silverorange/swat | SwatDB/SwatDBClassMap.php | SwatDBClassMap.get | public static function get($from_class_name)
{
$to_class_name = $from_class_name;
while (array_key_exists($from_class_name, self::$map)) {
$to_class_name = self::$map[$from_class_name];
if (!is_subclass_of($to_class_name, $from_class_name)) {
throw new SwatInvalidClassException(
sprintf(
'Invalid ' .
'class-mapping detected. %s is not a subclass of %s.',
$to_class_name,
$from_class_name
)
);
}
$from_class_name = $to_class_name;
}
return $to_class_name;
} | php | public static function get($from_class_name)
{
$to_class_name = $from_class_name;
while (array_key_exists($from_class_name, self::$map)) {
$to_class_name = self::$map[$from_class_name];
if (!is_subclass_of($to_class_name, $from_class_name)) {
throw new SwatInvalidClassException(
sprintf(
'Invalid ' .
'class-mapping detected. %s is not a subclass of %s.',
$to_class_name,
$from_class_name
)
);
}
$from_class_name = $to_class_name;
}
return $to_class_name;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"from_class_name",
")",
"{",
"$",
"to_class_name",
"=",
"$",
"from_class_name",
";",
"while",
"(",
"array_key_exists",
"(",
"$",
"from_class_name",
",",
"self",
"::",
"$",
"map",
")",
")",
"{",
"$",
"to_clas... | Resolves a class name from the class map
@param string $from_class_name the name of the class to resolve.
@return string the resolved class name. If no class mapping exists for
for the given class name, the same class name is
returned.
@throws SwatInvalidClassException if a mapped class is not a subclass of
its original class. | [
"Resolves",
"a",
"class",
"name",
"from",
"the",
"class",
"map"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBClassMap.php#L108-L130 | train |
silverorange/swat | SwatDB/SwatDBClassMap.php | SwatDBClassMap.addPath | public static function addPath($search_path)
{
if (!in_array($search_path, self::$search_paths, true)) {
// add path to front of array since it is more likely we will find
// class-definitions in manually added search paths
array_unshift(self::$search_paths, $search_path);
}
} | php | public static function addPath($search_path)
{
if (!in_array($search_path, self::$search_paths, true)) {
// add path to front of array since it is more likely we will find
// class-definitions in manually added search paths
array_unshift(self::$search_paths, $search_path);
}
} | [
"public",
"static",
"function",
"addPath",
"(",
"$",
"search_path",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"search_path",
",",
"self",
"::",
"$",
"search_paths",
",",
"true",
")",
")",
"{",
"// add path to front of array since it is more likely we will fi... | Adds a search path for class-definition files
When an undefined class is resolved, the class map attempts to find
and require a class-definition file for the class.
All search paths are relative to the PHP include path. The empty search
path ('.') is included by default.
@param string $search_path the path to search for class-definition files.
@see SwatDBClassMap::removePath() | [
"Adds",
"a",
"search",
"path",
"for",
"class",
"-",
"definition",
"files"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBClassMap.php#L148-L155 | train |
silverorange/swat | SwatDB/SwatDBClassMap.php | SwatDBClassMap.removePath | public static function removePath($search_path)
{
$index = array_search($search_path, self::$search_paths);
if ($index !== false) {
array_splice(self::$search_paths, $index, 1);
}
} | php | public static function removePath($search_path)
{
$index = array_search($search_path, self::$search_paths);
if ($index !== false) {
array_splice(self::$search_paths, $index, 1);
}
} | [
"public",
"static",
"function",
"removePath",
"(",
"$",
"search_path",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"search_path",
",",
"self",
"::",
"$",
"search_paths",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"array_splic... | Removes a search path for class-definition files
@param string $search_path the path to remove.
@see SwatDBClassMap::addPath() | [
"Removes",
"a",
"search",
"path",
"for",
"class",
"-",
"definition",
"files"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBClassMap.php#L167-L173 | train |
silverorange/swat | SwatDB/SwatDBClassMap.php | SwatDBClassMap.addMapping | public function addMapping($package_class_name, $class_name)
{
$this->mappings[$package_class_name] = $class_name;
self::add($package_class_name, $class_name);
} | php | public function addMapping($package_class_name, $class_name)
{
$this->mappings[$package_class_name] = $class_name;
self::add($package_class_name, $class_name);
} | [
"public",
"function",
"addMapping",
"(",
"$",
"package_class_name",
",",
"$",
"class_name",
")",
"{",
"$",
"this",
"->",
"mappings",
"[",
"$",
"package_class_name",
"]",
"=",
"$",
"class_name",
";",
"self",
"::",
"add",
"(",
"$",
"package_class_name",
",",
... | Adds a class-mapping to the class-mapping object
@param string $package_class_name the name of the package class to
override.
@param string $class_name the name of the site-specific class.
@deprecated Use the static method {@link SwatDBClassMap::add()}. | [
"Adds",
"a",
"class",
"-",
"mapping",
"to",
"the",
"class",
"-",
"mapping",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBClassMap.php#L251-L255 | train |
TeknooSoftware/states | src/State/StateTrait.php | StateTrait.getReflectionClass | private function getReflectionClass(): \ReflectionClass
{
if (null === $this->reflectionClass) {
$this->reflectionClass = new \ReflectionClass(\get_class($this));
}
return $this->reflectionClass;
} | php | private function getReflectionClass(): \ReflectionClass
{
if (null === $this->reflectionClass) {
$this->reflectionClass = new \ReflectionClass(\get_class($this));
}
return $this->reflectionClass;
} | [
"private",
"function",
"getReflectionClass",
"(",
")",
":",
"\\",
"ReflectionClass",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"reflectionClass",
")",
"{",
"$",
"this",
"->",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"\\",
"get_cla... | To build the ReflectionClass for the current object.
@api
@return \ReflectionClass
@throws \ReflectionException | [
"To",
"build",
"the",
"ReflectionClass",
"for",
"the",
"current",
"object",
"."
] | 0c675b768781ee3a3a15c2663cffec5d50c1d5fd | https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/State/StateTrait.php#L139-L146 | train |
TeknooSoftware/states | src/State/StateTrait.php | StateTrait.checkVisibilityProtected | private function checkVisibilityProtected(string &$methodName, string &$statedClassOrigin): bool
{
if (false === $this->reflectionsMethods[$methodName]->isPrivate()
&& !empty($statedClassOrigin)
&& ($statedClassOrigin === $this->statedClassName
|| \is_subclass_of($statedClassOrigin, $this->statedClassName))) {
//It's a public or protected method, do like if there is no method
return true;
}
return false;
} | php | private function checkVisibilityProtected(string &$methodName, string &$statedClassOrigin): bool
{
if (false === $this->reflectionsMethods[$methodName]->isPrivate()
&& !empty($statedClassOrigin)
&& ($statedClassOrigin === $this->statedClassName
|| \is_subclass_of($statedClassOrigin, $this->statedClassName))) {
//It's a public or protected method, do like if there is no method
return true;
}
return false;
} | [
"private",
"function",
"checkVisibilityProtected",
"(",
"string",
"&",
"$",
"methodName",
",",
"string",
"&",
"$",
"statedClassOrigin",
")",
":",
"bool",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"reflectionsMethods",
"[",
"$",
"methodName",
"]",
"-... | Can not access to private methods, only public and protected.
@param string $methodName
@param string $statedClassOrigin
@return bool | [
"Can",
"not",
"access",
"to",
"private",
"methods",
"only",
"public",
"and",
"protected",
"."
] | 0c675b768781ee3a3a15c2663cffec5d50c1d5fd | https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/State/StateTrait.php#L178-L189 | train |
TeknooSoftware/states | src/State/StateTrait.php | StateTrait.checkVisibilityPublic | private function checkVisibilityPublic(string &$methodName): bool
{
if (true === $this->reflectionsMethods[$methodName]->isPublic()) {
//It's a public method, do like if there is no method
return true;
}
return false;
} | php | private function checkVisibilityPublic(string &$methodName): bool
{
if (true === $this->reflectionsMethods[$methodName]->isPublic()) {
//It's a public method, do like if there is no method
return true;
}
return false;
} | [
"private",
"function",
"checkVisibilityPublic",
"(",
"string",
"&",
"$",
"methodName",
")",
":",
"bool",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"reflectionsMethods",
"[",
"$",
"methodName",
"]",
"->",
"isPublic",
"(",
")",
")",
"{",
"//It's a pu... | Can not access to protect and private method.
@param string $methodName
@return bool | [
"Can",
"not",
"access",
"to",
"protect",
"and",
"private",
"method",
"."
] | 0c675b768781ee3a3a15c2663cffec5d50c1d5fd | https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/State/StateTrait.php#L198-L206 | train |
brainworxx/kreXX | src/Analyse/Routing/Process/ProcessString.php | ProcessString.process | public function process(Model $model)
{
$data = $model->getData();
// Check if this is a possible callback.
// We are not going to analyse this further, because modern systems
// do not use these anymore.
if (function_exists($data) === true) {
$model->setIsCallback(true);
}
// Checking the encoding.
$encoding = $this->pool->encodingService->mbDetectEncoding($data);
if ($encoding === false) {
// Looks like we have a mixed encoded string.
// We need to tell the dev!
$length = $this->pool->encodingService->mbStrLen($data);
$strlen = 'broken encoding ' . $length;
$model->addToJson(static::META_ENCODING, 'broken');
} else {
// Normal encoding, nothing special here.
$length = $strlen = $this->pool->encodingService->mbStrLen($data, $encoding);
}
if ($length > 20) {
// Getting mime type from the string.
// With larger strings, there is a good chance that there is
// something interesting in there.
$model->addToJson(static::META_MIME_TYPE, $this->bufferInfo->buffer($data));
}
// Check, if we are handling large string, and if we need to use a
// preview (which we call "extra").
// We also need to check for linebreaks, because the preview can not
// display those.
if ($length > 50 || strstr($data, PHP_EOL) !== false) {
$cut = $this->pool->encodingService->encodeString(
$this->pool->encodingService->mbSubStr($data, 0, 50)
) . static::UNKNOWN_VALUE;
$data = $this->pool->encodingService->encodeString($data);
$model->setHasExtra(true)
->setNormal($cut)
->setData($data);
} else {
$model->setNormal($this->pool->encodingService->encodeString($data));
}
return $this->pool->render->renderSingleChild(
$model->setType(static::TYPE_STRING . $strlen)
->addToJson(static::META_LENGTH, $length)
);
} | php | public function process(Model $model)
{
$data = $model->getData();
// Check if this is a possible callback.
// We are not going to analyse this further, because modern systems
// do not use these anymore.
if (function_exists($data) === true) {
$model->setIsCallback(true);
}
// Checking the encoding.
$encoding = $this->pool->encodingService->mbDetectEncoding($data);
if ($encoding === false) {
// Looks like we have a mixed encoded string.
// We need to tell the dev!
$length = $this->pool->encodingService->mbStrLen($data);
$strlen = 'broken encoding ' . $length;
$model->addToJson(static::META_ENCODING, 'broken');
} else {
// Normal encoding, nothing special here.
$length = $strlen = $this->pool->encodingService->mbStrLen($data, $encoding);
}
if ($length > 20) {
// Getting mime type from the string.
// With larger strings, there is a good chance that there is
// something interesting in there.
$model->addToJson(static::META_MIME_TYPE, $this->bufferInfo->buffer($data));
}
// Check, if we are handling large string, and if we need to use a
// preview (which we call "extra").
// We also need to check for linebreaks, because the preview can not
// display those.
if ($length > 50 || strstr($data, PHP_EOL) !== false) {
$cut = $this->pool->encodingService->encodeString(
$this->pool->encodingService->mbSubStr($data, 0, 50)
) . static::UNKNOWN_VALUE;
$data = $this->pool->encodingService->encodeString($data);
$model->setHasExtra(true)
->setNormal($cut)
->setData($data);
} else {
$model->setNormal($this->pool->encodingService->encodeString($data));
}
return $this->pool->render->renderSingleChild(
$model->setType(static::TYPE_STRING . $strlen)
->addToJson(static::META_LENGTH, $length)
);
} | [
"public",
"function",
"process",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"data",
"=",
"$",
"model",
"->",
"getData",
"(",
")",
";",
"// Check if this is a possible callback.",
"// We are not going to analyse this further, because modern systems",
"// do not use these any... | Render a dump for a string value.
@param Model $model
The data we are analysing.
@return string
The rendered markup. | [
"Render",
"a",
"dump",
"for",
"a",
"string",
"value",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessString.php#L79-L132 | train |
silverorange/swat | Swat/SwatRemoveInputCell.php | SwatRemoveInputCell.init | public function init()
{
$row = $this->getInputRow();
if ($row === null) {
throw new SwatException(
'Remove input-cells can only be used ' .
'inside table-views with an input-row.'
);
}
$content = new SwatContentBlock();
ob_start();
$view = $this->getFirstAncestor('SwatTableView');
$view_id = $view === null ? null : $view->id;
$id = $view_id === null ? $row->id : $view_id . '_' . $row->id;
$anchor_tag = new SwatHtmlTag('a');
$anchor_tag->title = Swat::_('Remove this row');
$anchor_tag->class = 'swat-remove-input-cell-remove';
$anchor_tag->href = sprintf("javascript:%s_obj.removeRow('%%s');", $id);
$anchor_tag->setContent(Swat::_('Remove this row'));
$anchor_tag->display();
$content->content = ob_get_clean();
$content->content_type = 'text/xml';
// manually set the widget since setWidget() is over-ridden to throw
// an exception.
$this->widget = $content;
$content->parent = $this;
} | php | public function init()
{
$row = $this->getInputRow();
if ($row === null) {
throw new SwatException(
'Remove input-cells can only be used ' .
'inside table-views with an input-row.'
);
}
$content = new SwatContentBlock();
ob_start();
$view = $this->getFirstAncestor('SwatTableView');
$view_id = $view === null ? null : $view->id;
$id = $view_id === null ? $row->id : $view_id . '_' . $row->id;
$anchor_tag = new SwatHtmlTag('a');
$anchor_tag->title = Swat::_('Remove this row');
$anchor_tag->class = 'swat-remove-input-cell-remove';
$anchor_tag->href = sprintf("javascript:%s_obj.removeRow('%%s');", $id);
$anchor_tag->setContent(Swat::_('Remove this row'));
$anchor_tag->display();
$content->content = ob_get_clean();
$content->content_type = 'text/xml';
// manually set the widget since setWidget() is over-ridden to throw
// an exception.
$this->widget = $content;
$content->parent = $this;
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"getInputRow",
"(",
")",
";",
"if",
"(",
"$",
"row",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"'Remove input-cells can only be used '",
".",
"'inside tab... | Sets the remove widget for this input cell
In SwatRemoveInputCell objects the remove widget is automatically set to
a SwatContentBlock with predefined content for the remove link.
@throws SwatException | [
"Sets",
"the",
"remove",
"widget",
"for",
"this",
"input",
"cell"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRemoveInputCell.php#L32-L65 | train |
silverorange/swat | Swat/SwatRemoveInputCell.php | SwatRemoveInputCell.display | public function display($replicator_id)
{
$widget = $this->getClonedWidget($replicator_id);
// substitute the replicator_id into the content block's contents
$widget->content = str_replace('%s', $replicator_id, $widget->content);
$widget->display();
} | php | public function display($replicator_id)
{
$widget = $this->getClonedWidget($replicator_id);
// substitute the replicator_id into the content block's contents
$widget->content = str_replace('%s', $replicator_id, $widget->content);
$widget->display();
} | [
"public",
"function",
"display",
"(",
"$",
"replicator_id",
")",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"getClonedWidget",
"(",
"$",
"replicator_id",
")",
";",
"// substitute the replicator_id into the content block's contents",
"$",
"widget",
"->",
"content",
... | Displays this remove input cell given a numeric row identifier
@param integer $replicator_id the numeric identifier of the input row
that is being displayed.
@see SwatInputCell::display() | [
"Displays",
"this",
"remove",
"input",
"cell",
"given",
"a",
"numeric",
"row",
"identifier"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRemoveInputCell.php#L78-L84 | train |
brainworxx/kreXX | src/Errorhandler/AbstractError.php | AbstractError.translateErrorType | protected function translateErrorType($errorint)
{
if (isset($this->errorTranslation[$errorint]) === true) {
return $this->errorTranslation[$errorint];
}
// Fallback to 'unknown'.
return array('Unknown error', 'unknown');
} | php | protected function translateErrorType($errorint)
{
if (isset($this->errorTranslation[$errorint]) === true) {
return $this->errorTranslation[$errorint];
}
// Fallback to 'unknown'.
return array('Unknown error', 'unknown');
} | [
"protected",
"function",
"translateErrorType",
"(",
"$",
"errorint",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errorTranslation",
"[",
"$",
"errorint",
"]",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"errorTranslation",
"[",
... | Translates the error number into human readable text.
It also includes the corresponding config
setting, so we can decide if we want to output
anything.
@param int $errorint
The error number.
@return array
The translated type and the setting. | [
"Translates",
"the",
"error",
"number",
"into",
"human",
"readable",
"text",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Errorhandler/AbstractError.php#L133-L141 | train |
silverorange/swat | Swat/SwatCheckAll.php | SwatCheckAll.display | public function display()
{
if (!$this->visible) {
return;
}
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
$label_tag = new SwatHtmlTag('label');
$label_tag->for = $this->id . '_value';
$label_tag->open();
$old_id = $this->id;
$this->id .= '_value';
parent::display();
$this->id = $old_id;
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-check-all-title';
$span_tag->setContent($this->title, $this->content_type);
$span_tag->display();
$label_tag->close();
if ($this->extended_count > $this->visible_count) {
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id . '_extended';
$div_tag->class = 'swat-hidden swat-extended-check-all';
$div_tag->open();
echo $this->getExtendedTitle();
$div_tag->close();
}
$div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | php | public function display()
{
if (!$this->visible) {
return;
}
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
$label_tag = new SwatHtmlTag('label');
$label_tag->for = $this->id . '_value';
$label_tag->open();
$old_id = $this->id;
$this->id .= '_value';
parent::display();
$this->id = $old_id;
$span_tag = new SwatHtmlTag('span');
$span_tag->class = 'swat-check-all-title';
$span_tag->setContent($this->title, $this->content_type);
$span_tag->display();
$label_tag->close();
if ($this->extended_count > $this->visible_count) {
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id . '_extended';
$div_tag->class = 'swat-hidden swat-extended-check-all';
$div_tag->open();
echo $this->getExtendedTitle();
$div_tag->close();
}
$div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"$",
"div_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
"div_tag",
"->",
"id",
"=",
"$",
"this",
"->",
"id... | Displays this check-all widget | [
"Displays",
"this",
"check",
"-",
"all",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckAll.php#L100-L139 | train |
zeroem/ZeroemCurlBundle | Curl/CurlOptions.php | CurlOptions.loadOptions | static private function loadOptions() {
if (static::$option_value_types) {
return;
}
$options = array(
'CURLOPT_AUTOREFERER' => "bool",
'CURLOPT_BINARYTRANSFER' => "bool",
'CURLOPT_COOKIESESSION' => "bool",
'CURLOPT_CERTINFO' => "bool",
'CURLOPT_CRLF' => "bool",
'CURLOPT_DNS_USE_GLOBAL_CACHE' => "bool",
'CURLOPT_FAILONERROR' => "bool",
'CURLOPT_FILETIME' => "bool",
'CURLOPT_FOLLOWLOCATION' => "bool",
'CURLOPT_FORBID_REUSE' => "bool",
'CURLOPT_FRESH_CONNECT' => "bool",
'CURLOPT_FTP_USE_EPRT' => "bool",
'CURLOPT_FTP_USE_EPSV' => "bool",
'CURLOPT_FTP_CREATE_MISSING_DIRS' => "bool",
'CURLOPT_FTPAPPEND' => "bool",
'CURLOPT_FTPASCII' => "bool",
'CURLOPT_FTPLISTONLY' => "bool",
'CURLOPT_HEADER' => "bool",
'CURLINFO_HEADER_OUT' => "bool",
'CURLOPT_HTTPGET' => "bool",
'CURLOPT_HTTPPROXYTUNNEL' => "bool",
'CURLOPT_MUTE' => "bool",
'CURLOPT_NETRC' => "bool",
'CURLOPT_NOBODY' => "bool",
'CURLOPT_NOPROGRESS' => "bool",
'CURLOPT_NOSIGNAL' => "bool",
'CURLOPT_POST' => "bool",
'CURLOPT_PUT' => "bool",
'CURLOPT_RETURNTRANSFER' => "bool",
'CURLOPT_SSL_VERIFYPEER' => "bool",
'CURLOPT_TRANSFERTEXT' => "bool",
'CURLOPT_UNRESTRICTED_AUTH' => "bool",
'CURLOPT_UPLOAD' => "bool",
'CURLOPT_VERBOSE' => "bool",
'CURLOPT_BUFFERSIZE' => "int",
'CURLOPT_CLOSEPOLICY' => "int",
'CURLOPT_CONNECTTIMEOUT' => "int",
'CURLOPT_CONNECTTIMEOUT_MS' => "int",
'CURLOPT_DNS_CACHE_TIMEOUT' => "int",
'CURLOPT_FTPSSLAUTH' => "int",
'CURLOPT_HTTP_VERSION' => "int",
'CURLOPT_HTTPAUTH' => "int",
'CURLOPT_INFILESIZE' => "int",
'CURLOPT_LOW_SPEED_LIMIT' => "int",
'CURLOPT_LOW_SPEED_TIME' => "int",
'CURLOPT_MAXCONNECTS' => "int",
'CURLOPT_MAXREDIRS' => "int",
'CURLOPT_PORT' => "int",
'CURLOPT_PROTOCOLS' => "int",
'CURLOPT_PROXYAUTH' => "int",
'CURLOPT_PROXYPORT' => "int",
'CURLOPT_PROXYTYPE' => "int",
'CURLOPT_REDIR_PROTOCOLS' => "int",
'CURLOPT_RESUME_FROM' => "int",
'CURLOPT_SSL_VERIFYHOST' => "int",
'CURLOPT_SSLVERSION' => "int",
'CURLOPT_TIMECONDITION' => "int",
'CURLOPT_TIMEOUT' => "int",
'CURLOPT_TIMEOUT_MS' => "int",
'CURLOPT_TIMEVALUE' => "int",
'CURLOPT_MAX_RECV_SPEED_LARGE' => "int",
'CURLOPT_MAX_SEND_SPEED_LARGE' => "int",
'CURLOPT_SSH_AUTH_TYPES' => "int",
'CURLOPT_CAINFO' => "string",
'CURLOPT_CAPATH' => "string",
'CURLOPT_COOKIE' => "string",
'CURLOPT_COOKIEFILE' => "string",
'CURLOPT_COOKIEJAR' => "string",
'CURLOPT_CUSTOMREQUEST' => "string",
'CURLOPT_EGDSOCKET' => "string",
'CURLOPT_ENCODING' => "string",
'CURLOPT_FTPPORT' => "string",
'CURLOPT_INTERFACE' => "string",
'CURLOPT_KEYPASSWD' => "string",
'CURLOPT_KRB4LEVEL' => "string",
'CURLOPT_POSTFIELDS' => array("string","array"),
'CURLOPT_PROXY' => "string",
'CURLOPT_PROXYUSERPWD' => "string",
'CURLOPT_RANDOM_FILE' => "string",
'CURLOPT_RANGE' => "string",
'CURLOPT_REFERER' => "string",
'CURLOPT_SSH_HOST_PUBLIC_KEY_MD5' => "string",
'CURLOPT_SSH_PUBLIC_KEYFILE' => "string",
'CURLOPT_SSH_PRIVATE_KEYFILE' => "string",
'CURLOPT_SSL_CIPHER_LIST' => "string",
'CURLOPT_SSLCERT' => "string",
'CURLOPT_SSLCERTPASSWD' => "string",
'CURLOPT_SSLCERTTYPE' => "string",
'CURLOPT_SSLENGINE' => "string",
'CURLOPT_SSLENGINE_DEFAULT' => "string",
'CURLOPT_SSLKEY' => "string",
'CURLOPT_SSLKEYPASSWD' => "string",
'CURLOPT_SSLKEYTYPE' => "string",
'CURLOPT_URL' => "string",
'CURLOPT_USERAGENT' => "string",
'CURLOPT_USERPWD' => "string",
'CURLOPT_HTTP200ALIASES' => "array",
'CURLOPT_HTTPHEADER' => "array",
'CURLOPT_POSTQUOTE' => "array",
'CURLOPT_QUOTE' => "array",
'CURLOPT_FILE' => "resource",
'CURLOPT_INFILE' => "resource",
'CURLOPT_STDERR' => "resource",
'CURLOPT_WRITEHEADER' => "resource",
'CURLOPT_HEADERFUNCTION' => "callable",
'CURLOPT_PASSWDFUNCTION' => "callable",
'CURLOPT_PROGRESSFUNCTION' => "callable",
'CURLOPT_READFUNCTION' => "callable",
'CURLOPT_WRITEFUNCTION' => "callable",
);
foreach ($options as $option => $type) {
if (defined($option)) {
static::$option_value_types[constant($option)] = $type;
}
}
} | php | static private function loadOptions() {
if (static::$option_value_types) {
return;
}
$options = array(
'CURLOPT_AUTOREFERER' => "bool",
'CURLOPT_BINARYTRANSFER' => "bool",
'CURLOPT_COOKIESESSION' => "bool",
'CURLOPT_CERTINFO' => "bool",
'CURLOPT_CRLF' => "bool",
'CURLOPT_DNS_USE_GLOBAL_CACHE' => "bool",
'CURLOPT_FAILONERROR' => "bool",
'CURLOPT_FILETIME' => "bool",
'CURLOPT_FOLLOWLOCATION' => "bool",
'CURLOPT_FORBID_REUSE' => "bool",
'CURLOPT_FRESH_CONNECT' => "bool",
'CURLOPT_FTP_USE_EPRT' => "bool",
'CURLOPT_FTP_USE_EPSV' => "bool",
'CURLOPT_FTP_CREATE_MISSING_DIRS' => "bool",
'CURLOPT_FTPAPPEND' => "bool",
'CURLOPT_FTPASCII' => "bool",
'CURLOPT_FTPLISTONLY' => "bool",
'CURLOPT_HEADER' => "bool",
'CURLINFO_HEADER_OUT' => "bool",
'CURLOPT_HTTPGET' => "bool",
'CURLOPT_HTTPPROXYTUNNEL' => "bool",
'CURLOPT_MUTE' => "bool",
'CURLOPT_NETRC' => "bool",
'CURLOPT_NOBODY' => "bool",
'CURLOPT_NOPROGRESS' => "bool",
'CURLOPT_NOSIGNAL' => "bool",
'CURLOPT_POST' => "bool",
'CURLOPT_PUT' => "bool",
'CURLOPT_RETURNTRANSFER' => "bool",
'CURLOPT_SSL_VERIFYPEER' => "bool",
'CURLOPT_TRANSFERTEXT' => "bool",
'CURLOPT_UNRESTRICTED_AUTH' => "bool",
'CURLOPT_UPLOAD' => "bool",
'CURLOPT_VERBOSE' => "bool",
'CURLOPT_BUFFERSIZE' => "int",
'CURLOPT_CLOSEPOLICY' => "int",
'CURLOPT_CONNECTTIMEOUT' => "int",
'CURLOPT_CONNECTTIMEOUT_MS' => "int",
'CURLOPT_DNS_CACHE_TIMEOUT' => "int",
'CURLOPT_FTPSSLAUTH' => "int",
'CURLOPT_HTTP_VERSION' => "int",
'CURLOPT_HTTPAUTH' => "int",
'CURLOPT_INFILESIZE' => "int",
'CURLOPT_LOW_SPEED_LIMIT' => "int",
'CURLOPT_LOW_SPEED_TIME' => "int",
'CURLOPT_MAXCONNECTS' => "int",
'CURLOPT_MAXREDIRS' => "int",
'CURLOPT_PORT' => "int",
'CURLOPT_PROTOCOLS' => "int",
'CURLOPT_PROXYAUTH' => "int",
'CURLOPT_PROXYPORT' => "int",
'CURLOPT_PROXYTYPE' => "int",
'CURLOPT_REDIR_PROTOCOLS' => "int",
'CURLOPT_RESUME_FROM' => "int",
'CURLOPT_SSL_VERIFYHOST' => "int",
'CURLOPT_SSLVERSION' => "int",
'CURLOPT_TIMECONDITION' => "int",
'CURLOPT_TIMEOUT' => "int",
'CURLOPT_TIMEOUT_MS' => "int",
'CURLOPT_TIMEVALUE' => "int",
'CURLOPT_MAX_RECV_SPEED_LARGE' => "int",
'CURLOPT_MAX_SEND_SPEED_LARGE' => "int",
'CURLOPT_SSH_AUTH_TYPES' => "int",
'CURLOPT_CAINFO' => "string",
'CURLOPT_CAPATH' => "string",
'CURLOPT_COOKIE' => "string",
'CURLOPT_COOKIEFILE' => "string",
'CURLOPT_COOKIEJAR' => "string",
'CURLOPT_CUSTOMREQUEST' => "string",
'CURLOPT_EGDSOCKET' => "string",
'CURLOPT_ENCODING' => "string",
'CURLOPT_FTPPORT' => "string",
'CURLOPT_INTERFACE' => "string",
'CURLOPT_KEYPASSWD' => "string",
'CURLOPT_KRB4LEVEL' => "string",
'CURLOPT_POSTFIELDS' => array("string","array"),
'CURLOPT_PROXY' => "string",
'CURLOPT_PROXYUSERPWD' => "string",
'CURLOPT_RANDOM_FILE' => "string",
'CURLOPT_RANGE' => "string",
'CURLOPT_REFERER' => "string",
'CURLOPT_SSH_HOST_PUBLIC_KEY_MD5' => "string",
'CURLOPT_SSH_PUBLIC_KEYFILE' => "string",
'CURLOPT_SSH_PRIVATE_KEYFILE' => "string",
'CURLOPT_SSL_CIPHER_LIST' => "string",
'CURLOPT_SSLCERT' => "string",
'CURLOPT_SSLCERTPASSWD' => "string",
'CURLOPT_SSLCERTTYPE' => "string",
'CURLOPT_SSLENGINE' => "string",
'CURLOPT_SSLENGINE_DEFAULT' => "string",
'CURLOPT_SSLKEY' => "string",
'CURLOPT_SSLKEYPASSWD' => "string",
'CURLOPT_SSLKEYTYPE' => "string",
'CURLOPT_URL' => "string",
'CURLOPT_USERAGENT' => "string",
'CURLOPT_USERPWD' => "string",
'CURLOPT_HTTP200ALIASES' => "array",
'CURLOPT_HTTPHEADER' => "array",
'CURLOPT_POSTQUOTE' => "array",
'CURLOPT_QUOTE' => "array",
'CURLOPT_FILE' => "resource",
'CURLOPT_INFILE' => "resource",
'CURLOPT_STDERR' => "resource",
'CURLOPT_WRITEHEADER' => "resource",
'CURLOPT_HEADERFUNCTION' => "callable",
'CURLOPT_PASSWDFUNCTION' => "callable",
'CURLOPT_PROGRESSFUNCTION' => "callable",
'CURLOPT_READFUNCTION' => "callable",
'CURLOPT_WRITEFUNCTION' => "callable",
);
foreach ($options as $option => $type) {
if (defined($option)) {
static::$option_value_types[constant($option)] = $type;
}
}
} | [
"static",
"private",
"function",
"loadOptions",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"option_value_types",
")",
"{",
"return",
";",
"}",
"$",
"options",
"=",
"array",
"(",
"'CURLOPT_AUTOREFERER'",
"=>",
"\"bool\"",
",",
"'CURLOPT_BINARYTRANSFER'",
"=... | Checks which cURL constants is defined and loads them as valid options | [
"Checks",
"which",
"cURL",
"constants",
"is",
"defined",
"and",
"loads",
"them",
"as",
"valid",
"options"
] | 1045e2093bec5a013ff9458828721e581725f1a0 | https://github.com/zeroem/ZeroemCurlBundle/blob/1045e2093bec5a013ff9458828721e581725f1a0/Curl/CurlOptions.php#L23-L146 | train |
zeroem/ZeroemCurlBundle | Curl/CurlOptions.php | CurlOptions.checkOptionValue | static public function checkOptionValue($option, $value, $throw = true) {
if (!static::$option_value_types) {
static::loadOptions();
}
if(static::isValidOption($option)) {
$result = static::checkType($value, static::$option_value_types[$option]);
if(!$result && $throw) {
throw new \InvalidArgumentException("Invalid value for the given cURL option");
}
return $result;
} else {
throw new \InvalidArgumentException("Not a valid cURL option");
}
} | php | static public function checkOptionValue($option, $value, $throw = true) {
if (!static::$option_value_types) {
static::loadOptions();
}
if(static::isValidOption($option)) {
$result = static::checkType($value, static::$option_value_types[$option]);
if(!$result && $throw) {
throw new \InvalidArgumentException("Invalid value for the given cURL option");
}
return $result;
} else {
throw new \InvalidArgumentException("Not a valid cURL option");
}
} | [
"static",
"public",
"function",
"checkOptionValue",
"(",
"$",
"option",
",",
"$",
"value",
",",
"$",
"throw",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"option_value_types",
")",
"{",
"static",
"::",
"loadOptions",
"(",
")",
";",
"}",... | Check whether or not the value is a valid type for the given option
@param int $option An integer flag
@param mixed $value the value to be set to the integer flag
@return boolean Whether or not the value is of the correct type
@throws \InvalidArgumentException if the $option _is_not_ a valid cURL option | [
"Check",
"whether",
"or",
"not",
"the",
"value",
"is",
"a",
"valid",
"type",
"for",
"the",
"given",
"option"
] | 1045e2093bec5a013ff9458828721e581725f1a0 | https://github.com/zeroem/ZeroemCurlBundle/blob/1045e2093bec5a013ff9458828721e581725f1a0/Curl/CurlOptions.php#L172-L189 | train |
silverorange/swat | Swat/SwatAbstractOverlay.php | SwatAbstractOverlay.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$container_div_tag = new SwatHtmlTag('div');
$container_div_tag->id = $this->id;
$container_div_tag->class = $this->getCSSClassString();
$container_div_tag->open();
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'hidden';
$input_tag->id = $this->id . '_value';
$input_tag->name = $this->id;
$input_tag->value = $this->value;
$input_tag->accesskey = $this->access_key;
$input_tag->display();
$container_div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$container_div_tag = new SwatHtmlTag('div');
$container_div_tag->id = $this->id;
$container_div_tag->class = $this->getCSSClassString();
$container_div_tag->open();
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'hidden';
$input_tag->id = $this->id . '_value';
$input_tag->name = $this->id;
$input_tag->value = $this->value;
$input_tag->accesskey = $this->access_key;
$input_tag->display();
$container_div_tag->close();
Swat::displayInlineJavaScript($this->getInlineJavaScript());
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"$",
"container_div_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
... | Displays this overlay widget | [
"Displays",
"this",
"overlay",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatAbstractOverlay.php#L73-L98 | train |
rollun-com/rollun-datastore | src/Uploader/src/Iterator/DataStorePack.php | DataStorePack.getQuery | protected function getQuery()
{
$query = new Query();
if ($this->valid()) {
$query->setQuery(new GtNode($this->dataStore->getIdentifier(), $this->key()));
}
$query->setLimit(new LimitNode($this->limit));
$query->setSort(new SortNode([$this->dataStore->getIdentifier() => SortNode::SORT_ASC]));
return $query;
} | php | protected function getQuery()
{
$query = new Query();
if ($this->valid()) {
$query->setQuery(new GtNode($this->dataStore->getIdentifier(), $this->key()));
}
$query->setLimit(new LimitNode($this->limit));
$query->setSort(new SortNode([$this->dataStore->getIdentifier() => SortNode::SORT_ASC]));
return $query;
} | [
"protected",
"function",
"getQuery",
"(",
")",
"{",
"$",
"query",
"=",
"new",
"Query",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"query",
"->",
"setQuery",
"(",
"new",
"GtNode",
"(",
"$",
"this",
"->",
"dataSt... | Return query with limit and offset | [
"Return",
"query",
"with",
"limit",
"and",
"offset"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/Uploader/src/Iterator/DataStorePack.php#L64-L76 | train |
rollun-com/rollun-datastore | src/DataStore/src/DataStore/HttpClient.php | HttpClient.initHttpClient | protected function initHttpClient(string $method, string $uri, $ifMatch = false)
{
$httpClient = clone $this->client;
$httpClient->setUri($uri);
$httpClient->setOptions($this->options);
$headers['Content-Type'] = 'application/json';
$headers['Accept'] = 'application/json';
if ($ifMatch) {
$headers['If-Match'] = '*';
}
$httpClient->setHeaders($headers);
if (isset($this->login) && isset($this->password)) {
$httpClient->setAuth($this->login, $this->password);
}
$httpClient->setMethod($method);
return $httpClient;
} | php | protected function initHttpClient(string $method, string $uri, $ifMatch = false)
{
$httpClient = clone $this->client;
$httpClient->setUri($uri);
$httpClient->setOptions($this->options);
$headers['Content-Type'] = 'application/json';
$headers['Accept'] = 'application/json';
if ($ifMatch) {
$headers['If-Match'] = '*';
}
$httpClient->setHeaders($headers);
if (isset($this->login) && isset($this->password)) {
$httpClient->setAuth($this->login, $this->password);
}
$httpClient->setMethod($method);
return $httpClient;
} | [
"protected",
"function",
"initHttpClient",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"$",
"ifMatch",
"=",
"false",
")",
"{",
"$",
"httpClient",
"=",
"clone",
"$",
"this",
"->",
"client",
";",
"$",
"httpClient",
"->",
"setUri",
"(",
... | Create http client
@param string $method ('GET', 'HEAD', 'POST', 'PUT', 'DELETE')
@param string $uri
@param bool $ifMatch
@return Client | [
"Create",
"http",
"client"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/HttpClient.php#L110-L132 | train |
silverorange/swat | Swat/SwatReplicableNoteBookPage.php | SwatReplicableNoteBookPage.init | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$page = new SwatNoteBookPage();
$page->id = $page->getUniqueId();
$page_prototype_id = $page->id;
foreach ($children as $child_widget) {
$page->add($child_widget);
}
$this->add($page);
parent::init();
foreach ($this->replicators as $id => $title) {
$page = $this->getWidget($page_prototype_id, $id);
$page->title = $title;
}
$note_book = new SwatNoteBook($this->id . '_notebook');
foreach ($this->children as $child_widget) {
$page = $this->remove($child_widget);
$note_book->addPage($page);
}
$this->add($note_book);
} | php | public function init()
{
$children = array();
foreach ($this->children as $child_widget) {
$children[] = $this->remove($child_widget);
}
$page = new SwatNoteBookPage();
$page->id = $page->getUniqueId();
$page_prototype_id = $page->id;
foreach ($children as $child_widget) {
$page->add($child_widget);
}
$this->add($page);
parent::init();
foreach ($this->replicators as $id => $title) {
$page = $this->getWidget($page_prototype_id, $id);
$page->title = $title;
}
$note_book = new SwatNoteBook($this->id . '_notebook');
foreach ($this->children as $child_widget) {
$page = $this->remove($child_widget);
$note_book->addPage($page);
}
$this->add($note_book);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child_widget",
")",
"{",
"$",
"children",
"[",
"]",
"=",
"$",
"this",
"->",
"remove",
"(",
"$",
... | Initilizes this replicable notebook page | [
"Initilizes",
"this",
"replicable",
"notebook",
"page"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatReplicableNoteBookPage.php#L24-L56 | train |
silverorange/swat | Swat/SwatGroupedFlydown.php | SwatGroupedFlydown.display | public function display()
{
if (!$this->visible) {
return;
}
SwatWidget::display();
// tree is copied for display so we can add a blank node if show_blank
// is true
$display_tree = $this->getDisplayTree();
$count = count($display_tree) - 1;
// only show a select if there is more than one option
if ($count > 1) {
$select_tag = new SwatHtmlTag('select');
$select_tag->name = $this->id;
$select_tag->id = $this->id;
$select_tag->class = $this->getCSSClassString();
if (!$this->isSensitive()) {
$select_tag->disabled = 'disabled';
}
$select_tag->open();
foreach ($display_tree->getChildren() as $child) {
$this->displayNode($child, 1);
}
$select_tag->close();
} elseif ($count === 1) {
// get first and only element
$children = $display_tree->getChildren();
$option = reset($children)->getOption();
$this->displaySingle($option);
}
} | php | public function display()
{
if (!$this->visible) {
return;
}
SwatWidget::display();
// tree is copied for display so we can add a blank node if show_blank
// is true
$display_tree = $this->getDisplayTree();
$count = count($display_tree) - 1;
// only show a select if there is more than one option
if ($count > 1) {
$select_tag = new SwatHtmlTag('select');
$select_tag->name = $this->id;
$select_tag->id = $this->id;
$select_tag->class = $this->getCSSClassString();
if (!$this->isSensitive()) {
$select_tag->disabled = 'disabled';
}
$select_tag->open();
foreach ($display_tree->getChildren() as $child) {
$this->displayNode($child, 1);
}
$select_tag->close();
} elseif ($count === 1) {
// get first and only element
$children = $display_tree->getChildren();
$option = reset($children)->getOption();
$this->displaySingle($option);
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"SwatWidget",
"::",
"display",
"(",
")",
";",
"// tree is copied for display so we can add a blank node if show_blank",
"// is true",
"$",
... | Displays this grouped flydown
Displays this flydown as a XHTML select. Level 1 tree nodes are
displayed as optgroups if their value is null, they have children and
they are not dividers. | [
"Displays",
"this",
"grouped",
"flydown"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupedFlydown.php#L43-L80 | train |
silverorange/swat | Swat/SwatGroupedFlydown.php | SwatGroupedFlydown.checkTree | protected function checkTree(SwatTreeFlydownNode $tree, $level = 0)
{
if ($level > 2) {
throw new SwatException(
'SwatGroupedFlydown tree must not be ' .
'more than 3 levels including the root node.'
);
}
foreach ($tree->getChildren() as $child) {
$this->checkTree($child, $level + 1);
}
} | php | protected function checkTree(SwatTreeFlydownNode $tree, $level = 0)
{
if ($level > 2) {
throw new SwatException(
'SwatGroupedFlydown tree must not be ' .
'more than 3 levels including the root node.'
);
}
foreach ($tree->getChildren() as $child) {
$this->checkTree($child, $level + 1);
}
} | [
"protected",
"function",
"checkTree",
"(",
"SwatTreeFlydownNode",
"$",
"tree",
",",
"$",
"level",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"level",
">",
"2",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"'SwatGroupedFlydown tree must not be '",
".",
"'more than ... | Checks a tree to ensure it is valid for a grouped flydown
@param SwatTreeFlydownNode the tree to check.
@throws SwatException if the tree is not valid for a grouped flydown. | [
"Checks",
"a",
"tree",
"to",
"ensure",
"it",
"is",
"valid",
"for",
"a",
"grouped",
"flydown"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupedFlydown.php#L92-L104 | train |
silverorange/swat | Swat/SwatGroupedFlydown.php | SwatGroupedFlydown.displayNode | protected function displayNode(
SwatTreeFlydownNode $node,
$level = 0,
$selected = false
) {
$children = $node->getChildren();
$flydown_option = $node->getOption();
if (
$level == 1 &&
count($children) > 0 &&
end($flydown_option->value) === null &&
!($flydown_option instanceof SwatFlydownDivider)
) {
$optgroup_tag = new SwatHtmlTag('optgroup');
$optgroup_tag->label = $flydown_option->title;
$optgroup_tag->open();
foreach ($node->getChildren() as $child_node) {
$this->displayNode($child_node, $level + 1, $selected);
}
$optgroup_tag->close();
} else {
$option_tag = new SwatHtmlTag('option');
if ($this->serialize_values) {
$salt = $this->getForm()->getSalt();
$option_tag->value = SwatString::signedSerialize(
$flydown_option->value,
$salt
);
} else {
$option_tag->value = (string) $flydown_option->values;
}
if ($flydown_option instanceof SwatFlydownDivider) {
$option_tag->disabled = 'disabled';
$option_tag->class = 'swat-flydown-option-divider';
} else {
$option_tag->removeAttribute('disabled');
$option_tag->removeAttribute('class');
}
if (
$this->path === $flydown_option->value &&
$selected === false &&
!($flydown_option instanceof SwatFlydownDivider)
) {
$option_tag->selected = 'selected';
$selected = true;
} else {
$option_tag->removeAttribute('selected');
}
$option_tag->setContent($flydown_option->title);
$option_tag->display();
foreach ($children as $child_node) {
$this->displayNode($child_node, $level + 1, $selected);
}
}
} | php | protected function displayNode(
SwatTreeFlydownNode $node,
$level = 0,
$selected = false
) {
$children = $node->getChildren();
$flydown_option = $node->getOption();
if (
$level == 1 &&
count($children) > 0 &&
end($flydown_option->value) === null &&
!($flydown_option instanceof SwatFlydownDivider)
) {
$optgroup_tag = new SwatHtmlTag('optgroup');
$optgroup_tag->label = $flydown_option->title;
$optgroup_tag->open();
foreach ($node->getChildren() as $child_node) {
$this->displayNode($child_node, $level + 1, $selected);
}
$optgroup_tag->close();
} else {
$option_tag = new SwatHtmlTag('option');
if ($this->serialize_values) {
$salt = $this->getForm()->getSalt();
$option_tag->value = SwatString::signedSerialize(
$flydown_option->value,
$salt
);
} else {
$option_tag->value = (string) $flydown_option->values;
}
if ($flydown_option instanceof SwatFlydownDivider) {
$option_tag->disabled = 'disabled';
$option_tag->class = 'swat-flydown-option-divider';
} else {
$option_tag->removeAttribute('disabled');
$option_tag->removeAttribute('class');
}
if (
$this->path === $flydown_option->value &&
$selected === false &&
!($flydown_option instanceof SwatFlydownDivider)
) {
$option_tag->selected = 'selected';
$selected = true;
} else {
$option_tag->removeAttribute('selected');
}
$option_tag->setContent($flydown_option->title);
$option_tag->display();
foreach ($children as $child_node) {
$this->displayNode($child_node, $level + 1, $selected);
}
}
} | [
"protected",
"function",
"displayNode",
"(",
"SwatTreeFlydownNode",
"$",
"node",
",",
"$",
"level",
"=",
"0",
",",
"$",
"selected",
"=",
"false",
")",
"{",
"$",
"children",
"=",
"$",
"node",
"->",
"getChildren",
"(",
")",
";",
"$",
"flydown_option",
"=",... | Displays a grouped tree flydown node and its child nodes
Level 1 tree nodes are displayed as optgroups if their value is null,
they have children and they are not dividers.
@param SwatTreeFlydownNode $node the node to display.
@param integer $level the current level of the tree node.
@param array $path an array of values representing the tree path to
this node.
@param boolean $selected whether or not an element has been selected
yet. | [
"Displays",
"a",
"grouped",
"tree",
"flydown",
"node",
"and",
"its",
"child",
"nodes"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupedFlydown.php#L122-L183 | train |
silverorange/swat | Swat/SwatGroupedFlydown.php | SwatGroupedFlydown.buildDisplayTree | protected function buildDisplayTree(
SwatTreeFlydownNode $tree,
SwatTreeFlydownNode $parent,
$path = array()
) {
$flydown_option = $tree->getOption();
$path[] = $flydown_option->value;
$new_node = new SwatTreeFlydownNode($path, $flydown_option->title);
$parent->addChild($new_node);
foreach ($tree->getChildren() as $child) {
$this->buildDisplayTree($child, $new_node, $path);
}
} | php | protected function buildDisplayTree(
SwatTreeFlydownNode $tree,
SwatTreeFlydownNode $parent,
$path = array()
) {
$flydown_option = $tree->getOption();
$path[] = $flydown_option->value;
$new_node = new SwatTreeFlydownNode($path, $flydown_option->title);
$parent->addChild($new_node);
foreach ($tree->getChildren() as $child) {
$this->buildDisplayTree($child, $new_node, $path);
}
} | [
"protected",
"function",
"buildDisplayTree",
"(",
"SwatTreeFlydownNode",
"$",
"tree",
",",
"SwatTreeFlydownNode",
"$",
"parent",
",",
"$",
"path",
"=",
"array",
"(",
")",
")",
"{",
"$",
"flydown_option",
"=",
"$",
"tree",
"->",
"getOption",
"(",
")",
";",
... | Builds this grouped flydown's display tree by copying nodes from this
grouped flydown's tree
@param SwatTreeFlydownNode $tree the source tree node to build from.
@param SwatTreeFlydownNode $parent the destination parent node to add
display tree nodes to.
@param array $path the current path of the display tree. | [
"Builds",
"this",
"grouped",
"flydown",
"s",
"display",
"tree",
"by",
"copying",
"nodes",
"from",
"this",
"grouped",
"flydown",
"s",
"tree"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupedFlydown.php#L197-L210 | train |
silverorange/swat | Swat/SwatGroupedFlydown.php | SwatGroupedFlydown.getDisplayTree | protected function getDisplayTree()
{
$display_tree = new SwatTreeFlydownNode(null, 'root');
if ($this->show_blank) {
$display_tree->addChild(
new SwatTreeFlydownNode(null, $this->blank_title)
);
}
foreach ($this->tree->getChildren() as $child) {
$this->buildDisplayTree($child, $display_tree);
}
return $display_tree;
} | php | protected function getDisplayTree()
{
$display_tree = new SwatTreeFlydownNode(null, 'root');
if ($this->show_blank) {
$display_tree->addChild(
new SwatTreeFlydownNode(null, $this->blank_title)
);
}
foreach ($this->tree->getChildren() as $child) {
$this->buildDisplayTree($child, $display_tree);
}
return $display_tree;
} | [
"protected",
"function",
"getDisplayTree",
"(",
")",
"{",
"$",
"display_tree",
"=",
"new",
"SwatTreeFlydownNode",
"(",
"null",
",",
"'root'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"show_blank",
")",
"{",
"$",
"display_tree",
"->",
"addChild",
"(",
"new",... | Gets the display tree of this grouped flydown
The display tree is copied from this grouped flydown's tree. If
{@link SwatGroupedFlydown::$show_blank} is true, a blank node is
inserted as the first child of the root node of the display tree.
The value of a display tree node is set to an array representing the
path to the node in the display tree.
@see setTree() | [
"Gets",
"the",
"display",
"tree",
"of",
"this",
"grouped",
"flydown"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupedFlydown.php#L227-L241 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.addMappingToRenderer | public function addMappingToRenderer(
$renderer,
$data_field,
$property,
$object = null
) {
if ($object !== null) {
$property = $renderer->getPropertyNameToMap($object, $property);
}
$mapping = new SwatCellRendererMapping($property, $data_field);
$this->renderers->addMappingToRenderer($renderer, $mapping);
if ($object !== null) {
$object->$property = $mapping;
}
return $mapping;
} | php | public function addMappingToRenderer(
$renderer,
$data_field,
$property,
$object = null
) {
if ($object !== null) {
$property = $renderer->getPropertyNameToMap($object, $property);
}
$mapping = new SwatCellRendererMapping($property, $data_field);
$this->renderers->addMappingToRenderer($renderer, $mapping);
if ($object !== null) {
$object->$property = $mapping;
}
return $mapping;
} | [
"public",
"function",
"addMappingToRenderer",
"(",
"$",
"renderer",
",",
"$",
"data_field",
",",
"$",
"property",
",",
"$",
"object",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"object",
"!==",
"null",
")",
"{",
"$",
"property",
"=",
"$",
"renderer",
"->",... | Links a data-field to a cell renderer property of a cell renderer
within this container
@param SwatCellRenderer $renderer the cell renderer in this container
onto which the data-field is to be
mapped.
@param string $data_field the field of the data model to map to the cell
renderer property.
@param string $property the property of the cell renderer to which the
<i>$data_field</i> is mapped.
@param SwatUIObject $object optional. The object containing the property
to map when the property does not belong to
the cell renderer itself. If unspecified,
the <i>$property</i> must be a property of
the given cell renderer.
@return SwatCellRendererMapping a new mapping object that has been
added to the renderer. | [
"Links",
"a",
"data",
"-",
"field",
"to",
"a",
"cell",
"renderer",
"property",
"of",
"a",
"cell",
"renderer",
"within",
"this",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L57-L75 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.addRenderer | public function addRenderer(SwatCellRenderer $renderer)
{
$this->renderers->addRenderer($renderer);
$renderer->parent = $this;
} | php | public function addRenderer(SwatCellRenderer $renderer)
{
$this->renderers->addRenderer($renderer);
$renderer->parent = $this;
} | [
"public",
"function",
"addRenderer",
"(",
"SwatCellRenderer",
"$",
"renderer",
")",
"{",
"$",
"this",
"->",
"renderers",
"->",
"addRenderer",
"(",
"$",
"renderer",
")",
";",
"$",
"renderer",
"->",
"parent",
"=",
"$",
"this",
";",
"}"
] | Adds a cell renderer to this container's set of renderers
@param SwatCellRenderer $renderer the renderer to add. | [
"Adds",
"a",
"cell",
"renderer",
"to",
"this",
"container",
"s",
"set",
"of",
"renderers"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L85-L89 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.getRenderers | public function getRenderers()
{
$out = array();
$renderers = clone $this->renderers;
foreach ($renderers as $renderer) {
$out[] = $renderer;
}
return $out;
} | php | public function getRenderers()
{
$out = array();
$renderers = clone $this->renderers;
foreach ($renderers as $renderer) {
$out[] = $renderer;
}
return $out;
} | [
"public",
"function",
"getRenderers",
"(",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"$",
"renderers",
"=",
"clone",
"$",
"this",
"->",
"renderers",
";",
"foreach",
"(",
"$",
"renderers",
"as",
"$",
"renderer",
")",
"{",
"$",
"out",
"[",
"... | Gets the cell renderers of this container
@return array an array containing the cell renderers in this container. | [
"Gets",
"the",
"cell",
"renderers",
"of",
"this",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L99-L108 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.getHtmlHeadEntrySet | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
$renderers = $this->getRenderers();
foreach ($renderers as $renderer) {
$set->addEntrySet($renderer->getHtmlHeadEntrySet());
}
return $set;
} | php | public function getHtmlHeadEntrySet()
{
$set = parent::getHtmlHeadEntrySet();
$renderers = $this->getRenderers();
foreach ($renderers as $renderer) {
$set->addEntrySet($renderer->getHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getHtmlHeadEntrySet",
"(",
")",
";",
"$",
"renderers",
"=",
"$",
"this",
"->",
"getRenderers",
"(",
")",
";",
"foreach",
"(",
"$",
"renderers",
"as",
"$",
"rend... | Gets the SwatHtmlHeadEntry objects needed by this cell renderer
container
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by
this cell renderer container.
@see SwatUIObject::getHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"needed",
"by",
"this",
"cell",
"renderer",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L337-L347 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.getAvailableHtmlHeadEntrySet | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
$renderers = $this->getRenderers();
foreach ($renderers as $renderer) {
$set->addEntrySet($renderer->getAvailableHtmlHeadEntrySet());
}
return $set;
} | php | public function getAvailableHtmlHeadEntrySet()
{
$set = parent::getAvailableHtmlHeadEntrySet();
$renderers = $this->getRenderers();
foreach ($renderers as $renderer) {
$set->addEntrySet($renderer->getAvailableHtmlHeadEntrySet());
}
return $set;
} | [
"public",
"function",
"getAvailableHtmlHeadEntrySet",
"(",
")",
"{",
"$",
"set",
"=",
"parent",
"::",
"getAvailableHtmlHeadEntrySet",
"(",
")",
";",
"$",
"renderers",
"=",
"$",
"this",
"->",
"getRenderers",
"(",
")",
";",
"foreach",
"(",
"$",
"renderers",
"a... | Gets the SwatHtmlHeadEntry objects that may be needed by this cell
renderer container
@return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be
needed by this cell renderer container.
@see SwatUIObject::getAvailableHtmlHeadEntrySet() | [
"Gets",
"the",
"SwatHtmlHeadEntry",
"objects",
"that",
"may",
"be",
"needed",
"by",
"this",
"cell",
"renderer",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L361-L370 | train |
silverorange/swat | Swat/SwatCellRendererContainer.php | SwatCellRendererContainer.getRendererInlineJavaScript | public function getRendererInlineJavaScript()
{
$javascript = '';
foreach ($this->getRenderers() as $renderer) {
$renderer_javascript = $renderer->getInlineJavaScript();
if ($renderer_javascript != '') {
$javascript = "\n" . $renderer_javascript;
}
}
return $javascript;
} | php | public function getRendererInlineJavaScript()
{
$javascript = '';
foreach ($this->getRenderers() as $renderer) {
$renderer_javascript = $renderer->getInlineJavaScript();
if ($renderer_javascript != '') {
$javascript = "\n" . $renderer_javascript;
}
}
return $javascript;
} | [
"public",
"function",
"getRendererInlineJavaScript",
"(",
")",
"{",
"$",
"javascript",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRenderers",
"(",
")",
"as",
"$",
"renderer",
")",
"{",
"$",
"renderer_javascript",
"=",
"$",
"renderer",
"->",
"ge... | Gets inline JavaScript used by all cell renderers within this cell
renderer container
@return string the inline JavaScript used by all cell renderers within
this cell renderer container. | [
"Gets",
"inline",
"JavaScript",
"used",
"by",
"all",
"cell",
"renderers",
"within",
"this",
"cell",
"renderer",
"container"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererContainer.php#L382-L394 | train |
silverorange/swat | Swat/SwatNumber.php | SwatNumber.roundUp | public static function roundUp($value, $fractional_digits)
{
$power = pow(10, $fractional_digits);
$value = ceil($value * $power) / $power;
return $value;
} | php | public static function roundUp($value, $fractional_digits)
{
$power = pow(10, $fractional_digits);
$value = ceil($value * $power) / $power;
return $value;
} | [
"public",
"static",
"function",
"roundUp",
"(",
"$",
"value",
",",
"$",
"fractional_digits",
")",
"{",
"$",
"power",
"=",
"pow",
"(",
"10",
",",
"$",
"fractional_digits",
")",
";",
"$",
"value",
"=",
"ceil",
"(",
"$",
"value",
"*",
"$",
"power",
")",... | Rounds a number to the specified number of fractional digits using the
round-half-up rounding method
See {@link http://en.wikipedia.org/wiki/Rounding#Round_half_up}.
@param float $value the value to round.
@param integer $fractional_digits the number of fractional digits in the
rounded result.
@return float the rounded value. | [
"Rounds",
"a",
"number",
"to",
"the",
"specified",
"number",
"of",
"fractional",
"digits",
"using",
"the",
"round",
"-",
"half",
"-",
"up",
"rounding",
"method"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNumber.php#L26-L32 | train |
rhoone/yii2-rhoone | base/Rhoone.php | Rhoone.search | public function search($keyword = "")
{
Yii::trace("Begin searching...", __METHOD__);
$matches = $this->match($keyword);
$results = [];
foreach ($matches as $extension) {
$results[$extension->extension->id()] = $extension->extension->search($keyword);
}
return $results;
} | php | public function search($keyword = "")
{
Yii::trace("Begin searching...", __METHOD__);
$matches = $this->match($keyword);
$results = [];
foreach ($matches as $extension) {
$results[$extension->extension->id()] = $extension->extension->search($keyword);
}
return $results;
} | [
"public",
"function",
"search",
"(",
"$",
"keyword",
"=",
"\"\"",
")",
"{",
"Yii",
"::",
"trace",
"(",
"\"Begin searching...\"",
",",
"__METHOD__",
")",
";",
"$",
"matches",
"=",
"$",
"this",
"->",
"match",
"(",
"$",
"keyword",
")",
";",
"$",
"results"... | Search for result to the keywords.
@param string $keyword | [
"Search",
"for",
"result",
"to",
"the",
"keywords",
"."
] | f6ae90d466ea6f34bba404be0aba03e37ef369ad | https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/Rhoone.php#L141-L150 | train |
silverorange/swat | Swat/SwatRadioButtonCellRenderer.php | SwatRadioButtonCellRenderer.process | public function process()
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$data = $form->getFormData();
if (isset($data[$this->id])) {
$this->selected_value = $data[$this->id];
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$selection = new SwatViewSelection(array(
$this->selected_value
));
$view->setSelection($selection, $this);
}
}
}
} | php | public function process()
{
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$data = $form->getFormData();
if (isset($data[$this->id])) {
$this->selected_value = $data[$this->id];
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$selection = new SwatViewSelection(array(
$this->selected_value
));
$view->setSelection($selection, $this);
}
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"!==",
"null",
"&&",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"form",
"->... | Processes this radio button cell renderer | [
"Processes",
"this",
"radio",
"button",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioButtonCellRenderer.php#L101-L119 | train |
silverorange/swat | Swat/SwatRadioButtonCellRenderer.php | SwatRadioButtonCellRenderer.render | public function render()
{
if (!$this->visible) {
return;
}
parent::render();
if ($this->title !== null) {
$label_tag = new SwatHtmlTag('label');
$label_tag->for = $this->id . '_radio_button_' . $this->value;
$label_tag->setContent($this->title, $this->content_type);
$label_tag->open();
}
$radio_button_tag = new SwatHtmlTag('input');
$radio_button_tag->type = 'radio';
$radio_button_tag->name = $this->id;
$radio_button_tag->id = $this->id . '_radio_button_' . $this->value;
$radio_button_tag->value = $this->value;
if (!$this->sensitive) {
$radio_button_tag->disabled = 'disabled';
}
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$selection = $view->getSelection($this);
if ($selection->contains($this->value)) {
$radio_button_tag->checked = 'checked';
}
}
echo '<span class="swat-radio-wrapper">';
$radio_button_tag->display();
echo '<span class="swat-radio-shim"></span>';
echo '</span>';
if ($this->title !== null) {
$label_tag->displayContent();
$label_tag->close();
}
} | php | public function render()
{
if (!$this->visible) {
return;
}
parent::render();
if ($this->title !== null) {
$label_tag = new SwatHtmlTag('label');
$label_tag->for = $this->id . '_radio_button_' . $this->value;
$label_tag->setContent($this->title, $this->content_type);
$label_tag->open();
}
$radio_button_tag = new SwatHtmlTag('input');
$radio_button_tag->type = 'radio';
$radio_button_tag->name = $this->id;
$radio_button_tag->id = $this->id . '_radio_button_' . $this->value;
$radio_button_tag->value = $this->value;
if (!$this->sensitive) {
$radio_button_tag->disabled = 'disabled';
}
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$selection = $view->getSelection($this);
if ($selection->contains($this->value)) {
$radio_button_tag->checked = 'checked';
}
}
echo '<span class="swat-radio-wrapper">';
$radio_button_tag->display();
echo '<span class="swat-radio-shim"></span>';
echo '</span>';
if ($this->title !== null) {
$label_tag->displayContent();
$label_tag->close();
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"render",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"title",
"!==",
"null",
")",
"{",
"$",
"label_tag",
... | Renders this radio button cell renderer | [
"Renders",
"this",
"radio",
"button",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioButtonCellRenderer.php#L127-L168 | train |
silverorange/swat | Swat/SwatRadioButtonCellRenderer.php | SwatRadioButtonCellRenderer.getInlineJavaScript | public function getInlineJavaScript()
{
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$javascript = sprintf(
"var %s = new SwatRadioButtonCellRenderer('%s', %s);",
$this->id,
$this->id,
$view->id
);
} else {
$javascript = '';
}
return $javascript;
} | php | public function getInlineJavaScript()
{
$view = $this->getFirstAncestor('SwatView');
if ($view !== null) {
$javascript = sprintf(
"var %s = new SwatRadioButtonCellRenderer('%s', %s);",
$this->id,
$this->id,
$view->id
);
} else {
$javascript = '';
}
return $javascript;
} | [
"public",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getFirstAncestor",
"(",
"'SwatView'",
")",
";",
"if",
"(",
"$",
"view",
"!==",
"null",
")",
"{",
"$",
"javascript",
"=",
"sprintf",
"(",
"\"var %s = new SwatR... | Gets the inline JavaScript required by this radio button cell renderer
@return string the inline JavaScript required by this radio button cell
renderer. | [
"Gets",
"the",
"inline",
"JavaScript",
"required",
"by",
"this",
"radio",
"button",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioButtonCellRenderer.php#L194-L209 | train |
silverorange/swat | Swat/SwatGroupingFormField.php | SwatGroupingFormField.getTitleTag | protected function getTitleTag()
{
$legend_tag = new SwatHtmlTag('legend');
$legend_tag->setContent($this->title, $this->title_content_type);
return $legend_tag;
} | php | protected function getTitleTag()
{
$legend_tag = new SwatHtmlTag('legend');
$legend_tag->setContent($this->title, $this->title_content_type);
return $legend_tag;
} | [
"protected",
"function",
"getTitleTag",
"(",
")",
"{",
"$",
"legend_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'legend'",
")",
";",
"$",
"legend_tag",
"->",
"setContent",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"this",
"->",
"title_content_type",
")",
";",
... | Get a SwatHtmlTag to display the title.
Subclasses can change this to change their appearance.
@return SwatHtmlTag a tag object containing the title. | [
"Get",
"a",
"SwatHtmlTag",
"to",
"display",
"the",
"title",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatGroupingFormField.php#L24-L30 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.