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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GrahamCampbell/Laravel-Throttle | src/Transformers/TransformerFactory.php | TransformerFactory.make | public function make($data)
{
if (is_object($data) && $data instanceof Request) {
return new RequestTransformer();
}
if (is_array($data)) {
return new ArrayTransformer();
}
throw new InvalidArgumentException('An array, or an instance of Illuminate\Http\Request was expected.');
} | php | public function make($data)
{
if (is_object($data) && $data instanceof Request) {
return new RequestTransformer();
}
if (is_array($data)) {
return new ArrayTransformer();
}
throw new InvalidArgumentException('An array, or an instance of Illuminate\Http\Request was expected.');
} | [
"public",
"function",
"make",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
"&&",
"$",
"data",
"instanceof",
"Request",
")",
"{",
"return",
"new",
"RequestTransformer",
"(",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",... | Make a new transformer instance.
@param mixed $data
@throws \InvalidArgumentException
@return \GrahamCampbell\Throttle\Transformers\TransformerInterface | [
"Make",
"a",
"new",
"transformer",
"instance",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/Transformers/TransformerFactory.php#L35-L46 | train |
GrahamCampbell/Laravel-Throttle | src/Throttle.php | Throttle.get | public function get($data, int $limit = 10, int $time = 60)
{
$transformed = $this->transformer->make($data)->transform($data, $limit, $time);
if (!array_key_exists($key = $transformed->getKey(), $this->throttlers)) {
$this->throttlers[$key] = $this->factory->make($transformed);
}
return $this->throttlers[$key];
} | php | public function get($data, int $limit = 10, int $time = 60)
{
$transformed = $this->transformer->make($data)->transform($data, $limit, $time);
if (!array_key_exists($key = $transformed->getKey(), $this->throttlers)) {
$this->throttlers[$key] = $this->factory->make($transformed);
}
return $this->throttlers[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"data",
",",
"int",
"$",
"limit",
"=",
"10",
",",
"int",
"$",
"time",
"=",
"60",
")",
"{",
"$",
"transformed",
"=",
"$",
"this",
"->",
"transformer",
"->",
"make",
"(",
"$",
"data",
")",
"->",
"transform",
"... | Get a new throttler.
@param mixed $data
@param int $limit
@param int $time
@return \GrahamCampbell\Throttle\Throttlers\ThrottlerInterface | [
"Get",
"a",
"new",
"throttler",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/Throttle.php#L76-L85 | train |
GrahamCampbell/Laravel-Throttle | src/Data.php | Data.getKey | public function getKey()
{
if (!$this->key) {
$this->key = sha1($this->ip.$this->route);
}
return $this->key;
} | php | public function getKey()
{
if (!$this->key) {
$this->key = sha1($this->ip.$this->route);
}
return $this->key;
} | [
"public",
"function",
"getKey",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"key",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"sha1",
"(",
"$",
"this",
"->",
"ip",
".",
"$",
"this",
"->",
"route",
")",
";",
"}",
"return",
"$",
"this",
"->... | Get the unique key.
This key is used to identify the data between requests.
@return string | [
"Get",
"the",
"unique",
"key",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/Data.php#L123-L130 | train |
GrahamCampbell/Laravel-Throttle | src/Factories/CacheFactory.php | CacheFactory.make | public function make(Data $data)
{
return new CacheThrottler($this->cache->getStore(), $data->getKey(), $data->getLimit(), $data->getTime());
} | php | public function make(Data $data)
{
return new CacheThrottler($this->cache->getStore(), $data->getKey(), $data->getLimit(), $data->getTime());
} | [
"public",
"function",
"make",
"(",
"Data",
"$",
"data",
")",
"{",
"return",
"new",
"CacheThrottler",
"(",
"$",
"this",
"->",
"cache",
"->",
"getStore",
"(",
")",
",",
"$",
"data",
"->",
"getKey",
"(",
")",
",",
"$",
"data",
"->",
"getLimit",
"(",
"... | Make a new cache throttler instance.
@param \GrahamCampbell\Throttle\Data $data
@return \GrahamCampbell\Throttle\Throttlers\CacheThrottler | [
"Make",
"a",
"new",
"cache",
"throttler",
"instance",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/Factories/CacheFactory.php#L53-L56 | train |
GrahamCampbell/Laravel-Throttle | src/ThrottleServiceProvider.php | ThrottleServiceProvider.registerTransformer | protected function registerTransformer()
{
$this->app->singleton('throttle.transformer', function () {
return new TransformerFactory();
});
$this->app->alias('throttle.transformer', TransformerFactory::class);
$this->app->alias('throttle.transformer', TransformerFactoryInterface::class);
} | php | protected function registerTransformer()
{
$this->app->singleton('throttle.transformer', function () {
return new TransformerFactory();
});
$this->app->alias('throttle.transformer', TransformerFactory::class);
$this->app->alias('throttle.transformer', TransformerFactoryInterface::class);
} | [
"protected",
"function",
"registerTransformer",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'throttle.transformer'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"TransformerFactory",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->... | Register the transformer class.
@return void | [
"Register",
"the",
"transformer",
"class",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/ThrottleServiceProvider.php#L94-L102 | train |
GrahamCampbell/Laravel-Throttle | src/ThrottleServiceProvider.php | ThrottleServiceProvider.registerThrottle | protected function registerThrottle()
{
$this->app->singleton('throttle', function (Container $app) {
$factory = $app['throttle.factory'];
$transformer = $app['throttle.transformer'];
return new Throttle($factory, $transformer);
});
$this->app->alias('throttle', Throttle::class);
} | php | protected function registerThrottle()
{
$this->app->singleton('throttle', function (Container $app) {
$factory = $app['throttle.factory'];
$transformer = $app['throttle.transformer'];
return new Throttle($factory, $transformer);
});
$this->app->alias('throttle', Throttle::class);
} | [
"protected",
"function",
"registerThrottle",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'throttle'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"factory",
"=",
"$",
"app",
"[",
"'throttle.factory'",
"]",
";",
"$"... | Register the throttle class.
@return void | [
"Register",
"the",
"throttle",
"class",
"."
] | ab15752f6cfee2f9901a9af3524f53dfa95326cd | https://github.com/GrahamCampbell/Laravel-Throttle/blob/ab15752f6cfee2f9901a9af3524f53dfa95326cd/src/ThrottleServiceProvider.php#L109-L119 | train |
lexik/LexikFormFilterBundle | Event/Listener/PrepareListener.php | PrepareListener.onFilterBuilderPrepare | public function onFilterBuilderPrepare(PrepareEvent $event)
{
$qb = $event->getQueryBuilder();
$queryClasses = array(
'Doctrine\ORM\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery',
'Doctrine\DBAL\Query\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery',
'Doctrine\ODM\MongoDB\Query\Builder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\MongodbQuery',
);
foreach ($queryClasses as $builderClass => $queryClass) {
if (class_exists($builderClass) && $qb instanceof $builderClass) {
$query = new $queryClass($qb, $this->getForceCaseInsensitivity($qb), $this->encoding);
$event->setFilterQuery($query);
$event->stopPropagation();
return;
}
}
} | php | public function onFilterBuilderPrepare(PrepareEvent $event)
{
$qb = $event->getQueryBuilder();
$queryClasses = array(
'Doctrine\ORM\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery',
'Doctrine\DBAL\Query\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery',
'Doctrine\ODM\MongoDB\Query\Builder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\MongodbQuery',
);
foreach ($queryClasses as $builderClass => $queryClass) {
if (class_exists($builderClass) && $qb instanceof $builderClass) {
$query = new $queryClass($qb, $this->getForceCaseInsensitivity($qb), $this->encoding);
$event->setFilterQuery($query);
$event->stopPropagation();
return;
}
}
} | [
"public",
"function",
"onFilterBuilderPrepare",
"(",
"PrepareEvent",
"$",
"event",
")",
"{",
"$",
"qb",
"=",
"$",
"event",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"queryClasses",
"=",
"array",
"(",
"'Doctrine\\ORM\\QueryBuilder'",
"=>",
"'Lexik\\Bundle\\FormF... | Filter builder prepare event
@param PrepareEvent $event | [
"Filter",
"builder",
"prepare",
"event"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Event/Listener/PrepareListener.php#L83-L103 | train |
lexik/LexikFormFilterBundle | Filter/Doctrine/Expression/ExpressionBuilder.php | ExpressionBuilder.stringLike | public function stringLike($field, $value, $type = FilterOperands::STRING_CONTAINS)
{
$value = $this->convertTypeToMask($value, $type);
return $this->expr()->like(
$this->forceCaseInsensitivity ? $this->expr()->lower($field) : $field,
$this->expr()->literal($value)
);
} | php | public function stringLike($field, $value, $type = FilterOperands::STRING_CONTAINS)
{
$value = $this->convertTypeToMask($value, $type);
return $this->expr()->like(
$this->forceCaseInsensitivity ? $this->expr()->lower($field) : $field,
$this->expr()->literal($value)
);
} | [
"public",
"function",
"stringLike",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"type",
"=",
"FilterOperands",
"::",
"STRING_CONTAINS",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"convertTypeToMask",
"(",
"$",
"value",
",",
"$",
"type",
")",
"... | Get string like expression
@param string $field field name
@param string $value string value
@param int $type one of FilterOperands::STRING_* constant
@return \Doctrine\ORM\Query\Expr\Comparison|string | [
"Get",
"string",
"like",
"expression"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/Doctrine/Expression/ExpressionBuilder.php#L170-L178 | train |
lexik/LexikFormFilterBundle | Filter/Doctrine/Expression/ExpressionBuilder.php | ExpressionBuilder.convertToSqlDate | protected function convertToSqlDate($date, $isMax = false)
{
if (! $date instanceof \DateTime) {
return;
}
$copy = clone $date;
if ($isMax) {
$copy->modify('+1 day -1 second');
}
return $this->expr()->literal($copy->format(self::SQL_DATE_TIME));
} | php | protected function convertToSqlDate($date, $isMax = false)
{
if (! $date instanceof \DateTime) {
return;
}
$copy = clone $date;
if ($isMax) {
$copy->modify('+1 day -1 second');
}
return $this->expr()->literal($copy->format(self::SQL_DATE_TIME));
} | [
"protected",
"function",
"convertToSqlDate",
"(",
"$",
"date",
",",
"$",
"isMax",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"date",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
";",
"}",
"$",
"copy",
"=",
"clone",
"$",
"date",
";",
"if",
... | Normalize DateTime boundary
@param DateTime $date
@param bool $isMax
@return \Doctrine\ORM\Query\Expr\Literal|string | [
"Normalize",
"DateTime",
"boundary"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/Doctrine/Expression/ExpressionBuilder.php#L188-L201 | train |
lexik/LexikFormFilterBundle | Filter/Doctrine/Expression/ExpressionBuilder.php | ExpressionBuilder.convertToSqlDateTime | protected function convertToSqlDateTime($date)
{
if ($date instanceof \DateTime) {
$date = $this->expr()->literal($date->format(self::SQL_DATE_TIME));
}
return $date;
} | php | protected function convertToSqlDateTime($date)
{
if ($date instanceof \DateTime) {
$date = $this->expr()->literal($date->format(self::SQL_DATE_TIME));
}
return $date;
} | [
"protected",
"function",
"convertToSqlDateTime",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"instanceof",
"\\",
"DateTime",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"expr",
"(",
")",
"->",
"literal",
"(",
"$",
"date",
"->",
"format",
"... | Normalize date time boundary
@param DateTime|string $date
@return \Doctrine\ORM\Query\Expr\Literal | [
"Normalize",
"date",
"time",
"boundary"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/Doctrine/Expression/ExpressionBuilder.php#L209-L216 | train |
lexik/LexikFormFilterBundle | Filter/Doctrine/Expression/ExpressionBuilder.php | ExpressionBuilder.convertTypeToMask | protected function convertTypeToMask($value, $type)
{
if ($this->forceCaseInsensitivity) {
$value = $this->encoding ? mb_strtolower($value, $this->encoding) : mb_strtolower($value);
}
switch ($type) {
case FilterOperands::STRING_STARTS:
$value .= '%';
break;
case FilterOperands::STRING_ENDS:
$value = '%' . $value;
break;
case FilterOperands::STRING_CONTAINS:
$value = '%' . $value . '%';
break;
case FilterOperands::STRING_EQUALS:
break;
default:
throw new \InvalidArgumentException('Wrong type constant in string like expression mapper');
}
return $value;
} | php | protected function convertTypeToMask($value, $type)
{
if ($this->forceCaseInsensitivity) {
$value = $this->encoding ? mb_strtolower($value, $this->encoding) : mb_strtolower($value);
}
switch ($type) {
case FilterOperands::STRING_STARTS:
$value .= '%';
break;
case FilterOperands::STRING_ENDS:
$value = '%' . $value;
break;
case FilterOperands::STRING_CONTAINS:
$value = '%' . $value . '%';
break;
case FilterOperands::STRING_EQUALS:
break;
default:
throw new \InvalidArgumentException('Wrong type constant in string like expression mapper');
}
return $value;
} | [
"protected",
"function",
"convertTypeToMask",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"forceCaseInsensitivity",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"encoding",
"?",
"mb_strtolower",
"(",
"$",
"value",
",",... | Prepare value for like operation
@param string $value
@param int $type one of FilterOperands::STRING_*
@return string
@throws \InvalidArgumentException | [
"Prepare",
"value",
"for",
"like",
"operation"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/Doctrine/Expression/ExpressionBuilder.php#L228-L255 | train |
lexik/LexikFormFilterBundle | Filter/FilterOperands.php | FilterOperands.getNumberOperands | public static function getNumberOperands($includeSelector = false)
{
$values = array(
self::OPERATOR_EQUAL,
self::OPERATOR_GREATER_THAN,
self::OPERATOR_GREATER_THAN_EQUAL,
self::OPERATOR_LOWER_THAN,
self::OPERATOR_LOWER_THAN_EQUAL,
);
if ($includeSelector) {
$values[] = self::OPERAND_SELECTOR;
}
return $values;
} | php | public static function getNumberOperands($includeSelector = false)
{
$values = array(
self::OPERATOR_EQUAL,
self::OPERATOR_GREATER_THAN,
self::OPERATOR_GREATER_THAN_EQUAL,
self::OPERATOR_LOWER_THAN,
self::OPERATOR_LOWER_THAN_EQUAL,
);
if ($includeSelector) {
$values[] = self::OPERAND_SELECTOR;
}
return $values;
} | [
"public",
"static",
"function",
"getNumberOperands",
"(",
"$",
"includeSelector",
"=",
"false",
")",
"{",
"$",
"values",
"=",
"array",
"(",
"self",
"::",
"OPERATOR_EQUAL",
",",
"self",
"::",
"OPERATOR_GREATER_THAN",
",",
"self",
"::",
"OPERATOR_GREATER_THAN_EQUAL"... | Returns all available number operands.
@param boolean $includeSelector
@return array | [
"Returns",
"all",
"available",
"number",
"operands",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterOperands.php#L36-L51 | train |
lexik/LexikFormFilterBundle | Filter/FilterOperands.php | FilterOperands.getStringOperands | public static function getStringOperands($includeSelector = false)
{
$values = array(
self::STRING_STARTS,
self::STRING_ENDS,
self::STRING_EQUALS,
self::STRING_CONTAINS,
);
if ($includeSelector) {
$values[] = self::OPERAND_SELECTOR;
}
return $values;
} | php | public static function getStringOperands($includeSelector = false)
{
$values = array(
self::STRING_STARTS,
self::STRING_ENDS,
self::STRING_EQUALS,
self::STRING_CONTAINS,
);
if ($includeSelector) {
$values[] = self::OPERAND_SELECTOR;
}
return $values;
} | [
"public",
"static",
"function",
"getStringOperands",
"(",
"$",
"includeSelector",
"=",
"false",
")",
"{",
"$",
"values",
"=",
"array",
"(",
"self",
"::",
"STRING_STARTS",
",",
"self",
"::",
"STRING_ENDS",
",",
"self",
"::",
"STRING_EQUALS",
",",
"self",
"::"... | Returns all available string operands.
@param boolean $includeSelector
@return array | [
"Returns",
"all",
"available",
"string",
"operands",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterOperands.php#L59-L73 | train |
lexik/LexikFormFilterBundle | Filter/FilterOperands.php | FilterOperands.getStringOperandsChoices | public static function getStringOperandsChoices()
{
$choices = array();
$reflection = new \ReflectionClass(__CLASS__);
foreach ($reflection->getConstants() as $name => $value) {
if ('STRING_' === substr($name, 0, 7)) {
$choices[$value] = strtolower(str_replace('STRING_', 'text.', $name));
}
}
return array_flip($choices);
} | php | public static function getStringOperandsChoices()
{
$choices = array();
$reflection = new \ReflectionClass(__CLASS__);
foreach ($reflection->getConstants() as $name => $value) {
if ('STRING_' === substr($name, 0, 7)) {
$choices[$value] = strtolower(str_replace('STRING_', 'text.', $name));
}
}
return array_flip($choices);
} | [
"public",
"static",
"function",
"getStringOperandsChoices",
"(",
")",
"{",
"$",
"choices",
"=",
"array",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"__CLASS__",
")",
";",
"foreach",
"(",
"$",
"reflection",
"->",
"getConstants... | Retruns an array of available conditions patterns for string.
@return array | [
"Retruns",
"an",
"array",
"of",
"available",
"conditions",
"patterns",
"for",
"string",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterOperands.php#L99-L111 | train |
lexik/LexikFormFilterBundle | Filter/FilterOperands.php | FilterOperands.getStringOperandByString | public static function getStringOperandByString($operand)
{
if ($operand === null) {
return self::STRING_STARTS;
}
$name = strtoupper(str_replace('text.', 'STRING_', $operand));
$reflection = new \ReflectionClass(__CLASS__);
return $reflection->getConstant($name);
} | php | public static function getStringOperandByString($operand)
{
if ($operand === null) {
return self::STRING_STARTS;
}
$name = strtoupper(str_replace('text.', 'STRING_', $operand));
$reflection = new \ReflectionClass(__CLASS__);
return $reflection->getConstant($name);
} | [
"public",
"static",
"function",
"getStringOperandByString",
"(",
"$",
"operand",
")",
"{",
"if",
"(",
"$",
"operand",
"===",
"null",
")",
"{",
"return",
"self",
"::",
"STRING_STARTS",
";",
"}",
"$",
"name",
"=",
"strtoupper",
"(",
"str_replace",
"(",
"'tex... | Returns class constant string operand by given string.
@param String $operand
@return int | [
"Returns",
"class",
"constant",
"string",
"operand",
"by",
"given",
"string",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterOperands.php#L119-L129 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.addFilterConditions | public function addFilterConditions(FormInterface $form, $queryBuilder, $alias = null)
{
// create the right QueryInterface object
$event = new PrepareEvent($queryBuilder);
$this->dispatcher->dispatch(FilterEvents::PREPARE, $event);
if (!$event->getFilterQuery() instanceof QueryInterface) {
throw new \RuntimeException("Couldn't find any filter query object.");
}
$alias = (null !== $alias) ? $alias : $event->getFilterQuery()->getRootAlias();
// init parts (= ['joins' -> 'alias']) / the root alias does not target a join
$this->parts->add('__root__', $alias);
// get conditions nodes defined by the 'filter_condition_builder' option
// and add filters condition for each node
$this->conditionBuilder = $this->getConditionBuilder($form);
$this->addFilters($form, $event->getFilterQuery(), $alias);
// walk condition nodes to add condition on the query builder instance
$name = sprintf('lexik_filter.apply_filters.%s', $event->getFilterQuery()->getEventPartName());
$this->dispatcher->dispatch($name, new ApplyFilterConditionEvent($queryBuilder, $this->conditionBuilder));
$this->conditionBuilder = null;
return $queryBuilder;
} | php | public function addFilterConditions(FormInterface $form, $queryBuilder, $alias = null)
{
// create the right QueryInterface object
$event = new PrepareEvent($queryBuilder);
$this->dispatcher->dispatch(FilterEvents::PREPARE, $event);
if (!$event->getFilterQuery() instanceof QueryInterface) {
throw new \RuntimeException("Couldn't find any filter query object.");
}
$alias = (null !== $alias) ? $alias : $event->getFilterQuery()->getRootAlias();
// init parts (= ['joins' -> 'alias']) / the root alias does not target a join
$this->parts->add('__root__', $alias);
// get conditions nodes defined by the 'filter_condition_builder' option
// and add filters condition for each node
$this->conditionBuilder = $this->getConditionBuilder($form);
$this->addFilters($form, $event->getFilterQuery(), $alias);
// walk condition nodes to add condition on the query builder instance
$name = sprintf('lexik_filter.apply_filters.%s', $event->getFilterQuery()->getEventPartName());
$this->dispatcher->dispatch($name, new ApplyFilterConditionEvent($queryBuilder, $this->conditionBuilder));
$this->conditionBuilder = null;
return $queryBuilder;
} | [
"public",
"function",
"addFilterConditions",
"(",
"FormInterface",
"$",
"form",
",",
"$",
"queryBuilder",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"// create the right QueryInterface object",
"$",
"event",
"=",
"new",
"PrepareEvent",
"(",
"$",
"queryBuilder",
")"... | Build a filter query.
@param FormInterface $form
@param object $queryBuilder
@param string|null $alias
@return object filter builder
@throws \RuntimeException | [
"Build",
"a",
"filter",
"query",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L84-L111 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.addFilters | protected function addFilters(FormInterface $form, QueryInterface $filterQuery, $alias = null)
{
/** @var $child FormInterface */
foreach ($form->all() as $child) {
$formType = $child->getConfig()->getType()->getInnerType();
// this means we have a relation
if ($child->getConfig()->hasAttribute('add_shared')) {
$join = trim($alias . '.' . $child->getName(), '.');
$addSharedClosure = $child->getConfig()->getAttribute('add_shared');
if (!$addSharedClosure instanceof \Closure) {
throw new \RuntimeException('Please provide a closure to the "add_shared" option.');
}
$qbe = new FilterBuilderExecuter($filterQuery, $alias, $this->parts);
$addSharedClosure($qbe);
if (!$this->parts->has($join)) {
throw new \RuntimeException(sprintf('No alias found for relation "%s".', $join));
}
$isCollection = ($formType instanceof CollectionAdapterFilterType);
$this->addFilters($isCollection ? $child->get(0) : $child, $filterQuery, $this->parts->get($join));
// Doctrine2 embedded object case
} elseif ($formType instanceof EmbeddedFilterTypeInterface) {
$this->addFilters($child, $filterQuery, $alias . '.' . $child->getName());
// default case
} else {
$condition = $this->getFilterCondition($child, $formType, $filterQuery, $alias);
if ($condition instanceof ConditionInterface) {
$this->conditionBuilder->addCondition($condition);
}
}
}
} | php | protected function addFilters(FormInterface $form, QueryInterface $filterQuery, $alias = null)
{
/** @var $child FormInterface */
foreach ($form->all() as $child) {
$formType = $child->getConfig()->getType()->getInnerType();
// this means we have a relation
if ($child->getConfig()->hasAttribute('add_shared')) {
$join = trim($alias . '.' . $child->getName(), '.');
$addSharedClosure = $child->getConfig()->getAttribute('add_shared');
if (!$addSharedClosure instanceof \Closure) {
throw new \RuntimeException('Please provide a closure to the "add_shared" option.');
}
$qbe = new FilterBuilderExecuter($filterQuery, $alias, $this->parts);
$addSharedClosure($qbe);
if (!$this->parts->has($join)) {
throw new \RuntimeException(sprintf('No alias found for relation "%s".', $join));
}
$isCollection = ($formType instanceof CollectionAdapterFilterType);
$this->addFilters($isCollection ? $child->get(0) : $child, $filterQuery, $this->parts->get($join));
// Doctrine2 embedded object case
} elseif ($formType instanceof EmbeddedFilterTypeInterface) {
$this->addFilters($child, $filterQuery, $alias . '.' . $child->getName());
// default case
} else {
$condition = $this->getFilterCondition($child, $formType, $filterQuery, $alias);
if ($condition instanceof ConditionInterface) {
$this->conditionBuilder->addCondition($condition);
}
}
}
} | [
"protected",
"function",
"addFilters",
"(",
"FormInterface",
"$",
"form",
",",
"QueryInterface",
"$",
"filterQuery",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"/** @var $child FormInterface */",
"foreach",
"(",
"$",
"form",
"->",
"all",
"(",
")",
"as",
"$",
... | Add filter conditions on the condition node instance.
@param FormInterface $form
@param QueryInterface $filterQuery
@param string $alias
@throws \RuntimeException | [
"Add",
"filter",
"conditions",
"on",
"the",
"condition",
"node",
"instance",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L122-L162 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.getFilterCondition | protected function getFilterCondition(FormInterface $form, AbstractType $formType, QueryInterface $filterQuery, $alias)
{
$values = $this->prepareFilterValues($form, $formType);
$values += array('alias' => $alias);
$field = trim($values['alias'] . '.' . $form->getName(), '. ');
$condition = null;
// build a complete form name including parents
$completeName = $form->getName();
$parentForm = $form;
do {
$parentForm = $parentForm->getParent();
if (!is_numeric($parentForm->getName()) && $parentForm->getConfig()->getMapped()) { // skip collection numeric index and not mapped fields
$completeName = $parentForm->getName() . '.' . $completeName;
}
} while (!$parentForm->isRoot());
// apply the filter by using the closure set with the 'apply_filter' option
$callable = $form->getConfig()->getAttribute('apply_filter');
if (false === $callable) {
return null;
}
if ($callable instanceof \Closure) {
$condition = $callable($filterQuery, $field, $values);
} elseif (is_callable($callable)) {
$condition = call_user_func($callable, $filterQuery, $field, $values);
} else {
// trigger a specific or a global event name
$eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), $completeName);
if (!$this->dispatcher->hasListeners($eventName)) {
$eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), is_string($callable) ? $callable : $formType->getBlockPrefix());
}
$event = new GetFilterConditionEvent($filterQuery, $field, $values);
$this->dispatcher->dispatch($eventName, $event);
$condition = $event->getCondition();
}
// set condition path
if ($condition instanceof ConditionInterface) {
$condition->setName(
trim(substr($completeName, strpos($completeName, '.')), '.') // remove first level
);
}
return $condition;
} | php | protected function getFilterCondition(FormInterface $form, AbstractType $formType, QueryInterface $filterQuery, $alias)
{
$values = $this->prepareFilterValues($form, $formType);
$values += array('alias' => $alias);
$field = trim($values['alias'] . '.' . $form->getName(), '. ');
$condition = null;
// build a complete form name including parents
$completeName = $form->getName();
$parentForm = $form;
do {
$parentForm = $parentForm->getParent();
if (!is_numeric($parentForm->getName()) && $parentForm->getConfig()->getMapped()) { // skip collection numeric index and not mapped fields
$completeName = $parentForm->getName() . '.' . $completeName;
}
} while (!$parentForm->isRoot());
// apply the filter by using the closure set with the 'apply_filter' option
$callable = $form->getConfig()->getAttribute('apply_filter');
if (false === $callable) {
return null;
}
if ($callable instanceof \Closure) {
$condition = $callable($filterQuery, $field, $values);
} elseif (is_callable($callable)) {
$condition = call_user_func($callable, $filterQuery, $field, $values);
} else {
// trigger a specific or a global event name
$eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), $completeName);
if (!$this->dispatcher->hasListeners($eventName)) {
$eventName = sprintf('lexik_form_filter.apply.%s.%s', $filterQuery->getEventPartName(), is_string($callable) ? $callable : $formType->getBlockPrefix());
}
$event = new GetFilterConditionEvent($filterQuery, $field, $values);
$this->dispatcher->dispatch($eventName, $event);
$condition = $event->getCondition();
}
// set condition path
if ($condition instanceof ConditionInterface) {
$condition->setName(
trim(substr($completeName, strpos($completeName, '.')), '.') // remove first level
);
}
return $condition;
} | [
"protected",
"function",
"getFilterCondition",
"(",
"FormInterface",
"$",
"form",
",",
"AbstractType",
"$",
"formType",
",",
"QueryInterface",
"$",
"filterQuery",
",",
"$",
"alias",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"prepareFilterValues",
"(",
"... | Get the condition through event dispatcher.
@param FormInterface $form
@param AbstractType $formType
@param QueryInterface $filterQuery
@param string $alias
@return ConditionInterface|null | [
"Get",
"the",
"condition",
"through",
"event",
"dispatcher",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L173-L223 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.prepareFilterValues | protected function prepareFilterValues(FormInterface $form)
{
$config = $form->getConfig();
$values = $this->dataExtractor->extractData($form, $config->getOption('data_extraction_method', 'default'));
if ($config->hasAttribute('filter_options')) {
$values = array_merge($values, $config->getAttribute('filter_options'));
}
return $values;
} | php | protected function prepareFilterValues(FormInterface $form)
{
$config = $form->getConfig();
$values = $this->dataExtractor->extractData($form, $config->getOption('data_extraction_method', 'default'));
if ($config->hasAttribute('filter_options')) {
$values = array_merge($values, $config->getAttribute('filter_options'));
}
return $values;
} | [
"protected",
"function",
"prepareFilterValues",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"config",
"=",
"$",
"form",
"->",
"getConfig",
"(",
")",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"dataExtractor",
"->",
"extractData",
"(",
"$",
"form",
... | Prepare all values needed to apply the filter
@param FormInterface $form
@return array | [
"Prepare",
"all",
"values",
"needed",
"to",
"apply",
"the",
"filter"
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L231-L241 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.getConditionBuilder | protected function getConditionBuilder(Form $form)
{
$builderClosure = $form->getConfig()->getAttribute('filter_condition_builder');
$builder = new ConditionBuilder();
if ($builderClosure instanceof \Closure) {
$builderClosure($builder);
} else {
$this->buildDefaultConditionNode($form, $builder->root('AND'));
}
return $builder;
} | php | protected function getConditionBuilder(Form $form)
{
$builderClosure = $form->getConfig()->getAttribute('filter_condition_builder');
$builder = new ConditionBuilder();
if ($builderClosure instanceof \Closure) {
$builderClosure($builder);
} else {
$this->buildDefaultConditionNode($form, $builder->root('AND'));
}
return $builder;
} | [
"protected",
"function",
"getConditionBuilder",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"builderClosure",
"=",
"$",
"form",
"->",
"getConfig",
"(",
")",
"->",
"getAttribute",
"(",
"'filter_condition_builder'",
")",
";",
"$",
"builder",
"=",
"new",
"ConditionB... | Get the conditon builder object for the given form.
@param Form $form
@return ConditionBuilderInterface | [
"Get",
"the",
"conditon",
"builder",
"object",
"for",
"the",
"given",
"form",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L249-L262 | train |
lexik/LexikFormFilterBundle | Filter/FilterBuilderUpdater.php | FilterBuilderUpdater.buildDefaultConditionNode | protected function buildDefaultConditionNode(Form $form, ConditionNodeInterface $root, $parentName = '')
{
foreach ($form->all() as $child) {
$formType = $child->getConfig()->getType()->getInnerType();
$name = ('' !== $parentName) ? $parentName.'.'.$child->getName() : $child->getName();
if ($child->getConfig()->hasAttribute('add_shared') || $formType instanceof EmbeddedFilterTypeInterface) {
$isCollection = ($formType instanceof CollectionAdapterFilterType);
$this->buildDefaultConditionNode(
$isCollection ? $child->get(0) : $child,
$root->andX(),
$name
);
} else {
$root->field($name);
}
}
} | php | protected function buildDefaultConditionNode(Form $form, ConditionNodeInterface $root, $parentName = '')
{
foreach ($form->all() as $child) {
$formType = $child->getConfig()->getType()->getInnerType();
$name = ('' !== $parentName) ? $parentName.'.'.$child->getName() : $child->getName();
if ($child->getConfig()->hasAttribute('add_shared') || $formType instanceof EmbeddedFilterTypeInterface) {
$isCollection = ($formType instanceof CollectionAdapterFilterType);
$this->buildDefaultConditionNode(
$isCollection ? $child->get(0) : $child,
$root->andX(),
$name
);
} else {
$root->field($name);
}
}
} | [
"protected",
"function",
"buildDefaultConditionNode",
"(",
"Form",
"$",
"form",
",",
"ConditionNodeInterface",
"$",
"root",
",",
"$",
"parentName",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"form",
"->",
"all",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$"... | Create a default node hierarchy by using AND operator.
@param Form $form
@param ConditionNodeInterface $root
@param string $parentName | [
"Create",
"a",
"default",
"node",
"hierarchy",
"by",
"using",
"AND",
"operator",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/FilterBuilderUpdater.php#L271-L290 | train |
lexik/LexikFormFilterBundle | Filter/Condition/ConditionNode.php | ConditionNode.setCondition | public function setCondition($name, ConditionInterface $condition)
{
if (array_key_exists($name, $this->fields)) {
$this->fields[$name] = $condition;
return true;
}
$i = 0;
$end = count($this->children);
$set = false;
while ($i < $end && !$set) {
$set = $this->children[$i]->setCondition($name, $condition);
$i++;
}
return $set;
} | php | public function setCondition($name, ConditionInterface $condition)
{
if (array_key_exists($name, $this->fields)) {
$this->fields[$name] = $condition;
return true;
}
$i = 0;
$end = count($this->children);
$set = false;
while ($i < $end && !$set) {
$set = $this->children[$i]->setCondition($name, $condition);
$i++;
}
return $set;
} | [
"public",
"function",
"setCondition",
"(",
"$",
"name",
",",
"ConditionInterface",
"$",
"condition",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"fields",
")",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"nam... | Set the condition for the given field name.
@param string $name
@param ConditionInterface $condition
@return bool | [
"Set",
"the",
"condition",
"for",
"the",
"given",
"field",
"name",
"."
] | 92df0638173979dc906bda7a33a10b98429d2057 | https://github.com/lexik/LexikFormFilterBundle/blob/92df0638173979dc906bda7a33a10b98429d2057/Filter/Condition/ConditionNode.php#L117-L135 | train |
clue/reactphp-buzz | src/Io/Sender.php | Sender.createFromLoop | public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector = null, MessageFactory $messageFactory)
{
return new self(new HttpClient($loop, $connector), $messageFactory);
} | php | public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector = null, MessageFactory $messageFactory)
{
return new self(new HttpClient($loop, $connector), $messageFactory);
} | [
"public",
"static",
"function",
"createFromLoop",
"(",
"LoopInterface",
"$",
"loop",
",",
"ConnectorInterface",
"$",
"connector",
"=",
"null",
",",
"MessageFactory",
"$",
"messageFactory",
")",
"{",
"return",
"new",
"self",
"(",
"new",
"HttpClient",
"(",
"$",
... | create a new default sender attached to the given event loop
This method is used internally to create the "default sender".
You may also use this method if you need custom DNS or connector
settings. You can use this method manually like this:
```php
$connector = new \React\Socket\Connector($loop);
$sender = \Clue\React\Buzz\Io\Sender::createFromLoop($loop, $connector);
```
@param LoopInterface $loop
@param ConnectorInterface|null $connector
@return self | [
"create",
"a",
"new",
"default",
"sender",
"attached",
"to",
"the",
"given",
"event",
"loop"
] | 83cc87d19fdc031cff3ddf3629d52ca95cbfbc92 | https://github.com/clue/reactphp-buzz/blob/83cc87d19fdc031cff3ddf3629d52ca95cbfbc92/src/Io/Sender.php#L51-L54 | train |
clue/reactphp-buzz | src/Message/MessageFactory.php | MessageFactory.request | public function request($method, $uri, $headers = array(), $content = '')
{
return new Request($method, $uri, $headers, $this->body($content), '1.0');
} | php | public function request($method, $uri, $headers = array(), $content = '')
{
return new Request($method, $uri, $headers, $this->body($content), '1.0');
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"headers",
"=",
"array",
"(",
")",
",",
"$",
"content",
"=",
"''",
")",
"{",
"return",
"new",
"Request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"headers",
","... | Creates a new instance of RequestInterface for the given request parameters
@param string $method
@param string|UriInterface $uri
@param array $headers
@param string|ReadableStreamInterface $content
@return Request | [
"Creates",
"a",
"new",
"instance",
"of",
"RequestInterface",
"for",
"the",
"given",
"request",
"parameters"
] | 83cc87d19fdc031cff3ddf3629d52ca95cbfbc92 | https://github.com/clue/reactphp-buzz/blob/83cc87d19fdc031cff3ddf3629d52ca95cbfbc92/src/Message/MessageFactory.php#L26-L29 | train |
clue/reactphp-buzz | src/Message/MessageFactory.php | MessageFactory.response | public function response($version, $status, $reason, $headers = array(), $body = '')
{
return new Response($status, $headers, $this->body($body), $version, $reason);
} | php | public function response($version, $status, $reason, $headers = array(), $body = '')
{
return new Response($status, $headers, $this->body($body), $version, $reason);
} | [
"public",
"function",
"response",
"(",
"$",
"version",
",",
"$",
"status",
",",
"$",
"reason",
",",
"$",
"headers",
"=",
"array",
"(",
")",
",",
"$",
"body",
"=",
"''",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"status",
",",
"$",
"headers",... | Creates a new instance of ResponseInterface for the given response parameters
@param string $version
@param int $status
@param string $reason
@param array $headers
@param ReadableStreamInterface|string $body
@return Response
@uses self::body() | [
"Creates",
"a",
"new",
"instance",
"of",
"ResponseInterface",
"for",
"the",
"given",
"response",
"parameters"
] | 83cc87d19fdc031cff3ddf3629d52ca95cbfbc92 | https://github.com/clue/reactphp-buzz/blob/83cc87d19fdc031cff3ddf3629d52ca95cbfbc92/src/Message/MessageFactory.php#L42-L45 | train |
clue/reactphp-buzz | src/Message/MessageFactory.php | MessageFactory.body | public function body($body)
{
if ($body instanceof ReadableStreamInterface) {
return new ReadableBodyStream($body);
}
return \RingCentral\Psr7\stream_for($body);
} | php | public function body($body)
{
if ($body instanceof ReadableStreamInterface) {
return new ReadableBodyStream($body);
}
return \RingCentral\Psr7\stream_for($body);
} | [
"public",
"function",
"body",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"$",
"body",
"instanceof",
"ReadableStreamInterface",
")",
"{",
"return",
"new",
"ReadableBodyStream",
"(",
"$",
"body",
")",
";",
"}",
"return",
"\\",
"RingCentral",
"\\",
"Psr7",
"\\",
... | Creates a new instance of StreamInterface for the given body contents
@param ReadableStreamInterface|string $body
@return StreamInterface | [
"Creates",
"a",
"new",
"instance",
"of",
"StreamInterface",
"for",
"the",
"given",
"body",
"contents"
] | 83cc87d19fdc031cff3ddf3629d52ca95cbfbc92 | https://github.com/clue/reactphp-buzz/blob/83cc87d19fdc031cff3ddf3629d52ca95cbfbc92/src/Message/MessageFactory.php#L53-L60 | train |
clue/reactphp-buzz | src/Browser.php | Browser.withBase | public function withBase($baseUri)
{
$browser = clone $this;
$browser->baseUri = $this->messageFactory->uri($baseUri);
if ($browser->baseUri->getScheme() === '' || $browser->baseUri->getHost() === '') {
throw new \InvalidArgumentException('Base URI must be absolute');
}
return $browser;
} | php | public function withBase($baseUri)
{
$browser = clone $this;
$browser->baseUri = $this->messageFactory->uri($baseUri);
if ($browser->baseUri->getScheme() === '' || $browser->baseUri->getHost() === '') {
throw new \InvalidArgumentException('Base URI must be absolute');
}
return $browser;
} | [
"public",
"function",
"withBase",
"(",
"$",
"baseUri",
")",
"{",
"$",
"browser",
"=",
"clone",
"$",
"this",
";",
"$",
"browser",
"->",
"baseUri",
"=",
"$",
"this",
"->",
"messageFactory",
"->",
"uri",
"(",
"$",
"baseUri",
")",
";",
"if",
"(",
"$",
... | Changes the base URI used to resolve relative URIs to.
```php
$newBrowser = $browser->withBase('http://api.example.com/v3');
```
Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withBase()` method
actually returns a *new* [`Browser`](#browser) instance with the given base URI applied.
Any requests to relative URIs will then be processed by first prepending
the (absolute) base URI.
Please note that this merely prepends the base URI and does *not* resolve
any relative path references (like `../` etc.).
This is mostly useful for (RESTful) API calls where all endpoints (URIs)
are located under a common base URI scheme.
```php
// will request http://api.example.com/v3/example
$newBrowser->get('/example')->then(…);
```
By definition of this library, a given base URI MUST always absolute and
can not contain any placeholders.
@param string|UriInterface $baseUri absolute base URI
@return self
@throws InvalidArgumentException if the given $baseUri is not a valid absolute URI
@see self::withoutBase() | [
"Changes",
"the",
"base",
"URI",
"used",
"to",
"resolve",
"relative",
"URIs",
"to",
"."
] | 83cc87d19fdc031cff3ddf3629d52ca95cbfbc92 | https://github.com/clue/reactphp-buzz/blob/83cc87d19fdc031cff3ddf3629d52ca95cbfbc92/src/Browser.php#L268-L278 | train |
doctrine/DoctrineMongoDBBundle | DependencyInjection/DoctrineMongoDBExtension.php | DoctrineMongoDBExtension.load | public function load(array $configs, ContainerBuilder $container)
{
// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader->load('mongodb.xml');
if (empty($config['default_connection'])) {
$keys = array_keys($config['connections']);
$config['default_connection'] = reset($keys);
}
$container->setParameter('doctrine_mongodb.odm.default_connection', $config['default_connection']);
if (empty($config['default_document_manager'])) {
$keys = array_keys($config['document_managers']);
$config['default_document_manager'] = reset($keys);
}
$container->setParameter('doctrine_mongodb.odm.default_document_manager', $config['default_document_manager']);
// set some options as parameters and unset them
$config = $this->overrideParameters($config, $container);
// set the fixtures loader
$container->setParameter('doctrine_mongodb.odm.fixture_loader', $config['fixture_loader']);
// load the connections
$this->loadConnections($config['connections'], $container);
$config['document_managers'] = $this->fixManagersAutoMappings($config['document_managers'], $container->getParameter('kernel.bundles'));
// load the document managers
$this->loadDocumentManagers(
$config['document_managers'],
$config['default_document_manager'],
$config['default_database'],
$container
);
if ($config['resolve_target_documents']) {
$def = $container->findDefinition('doctrine_mongodb.odm.listeners.resolve_target_document');
foreach ($config['resolve_target_documents'] as $name => $implementation) {
$def->addMethodCall('addResolveTargetDocument', [$name, $implementation, []]);
}
$def->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'loadClassMetadata']);
}
// BC Aliases for Document Manager
$container->setAlias('doctrine.odm.mongodb.document_manager', new Alias('doctrine_mongodb.odm.document_manager'));
$container->registerForAutoconfiguration(ServiceDocumentRepositoryInterface::class)
->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
} | php | public function load(array $configs, ContainerBuilder $container)
{
// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader->load('mongodb.xml');
if (empty($config['default_connection'])) {
$keys = array_keys($config['connections']);
$config['default_connection'] = reset($keys);
}
$container->setParameter('doctrine_mongodb.odm.default_connection', $config['default_connection']);
if (empty($config['default_document_manager'])) {
$keys = array_keys($config['document_managers']);
$config['default_document_manager'] = reset($keys);
}
$container->setParameter('doctrine_mongodb.odm.default_document_manager', $config['default_document_manager']);
// set some options as parameters and unset them
$config = $this->overrideParameters($config, $container);
// set the fixtures loader
$container->setParameter('doctrine_mongodb.odm.fixture_loader', $config['fixture_loader']);
// load the connections
$this->loadConnections($config['connections'], $container);
$config['document_managers'] = $this->fixManagersAutoMappings($config['document_managers'], $container->getParameter('kernel.bundles'));
// load the document managers
$this->loadDocumentManagers(
$config['document_managers'],
$config['default_document_manager'],
$config['default_database'],
$container
);
if ($config['resolve_target_documents']) {
$def = $container->findDefinition('doctrine_mongodb.odm.listeners.resolve_target_document');
foreach ($config['resolve_target_documents'] as $name => $implementation) {
$def->addMethodCall('addResolveTargetDocument', [$name, $implementation, []]);
}
$def->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'loadClassMetadata']);
}
// BC Aliases for Document Manager
$container->setAlias('doctrine.odm.mongodb.document_manager', new Alias('doctrine_mongodb.odm.document_manager'));
$container->registerForAutoconfiguration(ServiceDocumentRepositoryInterface::class)
->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// Load DoctrineMongoDBBundle/Resources/config/mongodb.xml",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",... | Responds to the doctrine_mongodb configuration parameter. | [
"Responds",
"to",
"the",
"doctrine_mongodb",
"configuration",
"parameter",
"."
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/DependencyInjection/DoctrineMongoDBExtension.php#L33-L87 | train |
doctrine/DoctrineMongoDBBundle | DependencyInjection/DoctrineMongoDBExtension.php | DoctrineMongoDBExtension.overrideParameters | protected function overrideParameters($options, ContainerBuilder $container)
{
$overrides = [
'proxy_namespace',
'proxy_dir',
'auto_generate_proxy_classes',
'hydrator_namespace',
'hydrator_dir',
'auto_generate_hydrator_classes',
'default_commit_options',
'persistent_collection_dir',
'persistent_collection_namespace',
'auto_generate_persistent_collection_classes',
];
foreach ($overrides as $key) {
if (! isset($options[$key])) {
continue;
}
$container->setParameter('doctrine_mongodb.odm.' . $key, $options[$key]);
// the option should not be used, the parameter should be referenced
unset($options[$key]);
}
return $options;
} | php | protected function overrideParameters($options, ContainerBuilder $container)
{
$overrides = [
'proxy_namespace',
'proxy_dir',
'auto_generate_proxy_classes',
'hydrator_namespace',
'hydrator_dir',
'auto_generate_hydrator_classes',
'default_commit_options',
'persistent_collection_dir',
'persistent_collection_namespace',
'auto_generate_persistent_collection_classes',
];
foreach ($overrides as $key) {
if (! isset($options[$key])) {
continue;
}
$container->setParameter('doctrine_mongodb.odm.' . $key, $options[$key]);
// the option should not be used, the parameter should be referenced
unset($options[$key]);
}
return $options;
} | [
"protected",
"function",
"overrideParameters",
"(",
"$",
"options",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"overrides",
"=",
"[",
"'proxy_namespace'",
",",
"'proxy_dir'",
",",
"'auto_generate_proxy_classes'",
",",
"'hydrator_namespace'",
",",
"'hydr... | Uses some of the extension options to override DI extension parameters.
@param array $options The available configuration options
@param ContainerBuilder $container A ContainerBuilder instance | [
"Uses",
"some",
"of",
"the",
"extension",
"options",
"to",
"override",
"DI",
"extension",
"parameters",
"."
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/DependencyInjection/DoctrineMongoDBExtension.php#L95-L122 | train |
doctrine/DoctrineMongoDBBundle | DependencyInjection/DoctrineMongoDBExtension.php | DoctrineMongoDBExtension.normalizeDriverOptions | private function normalizeDriverOptions(array $connection)
{
$driverOptions = $connection['driverOptions'] ?? [];
$driverOptions['typeMap'] = DocumentManager::CLIENT_TYPEMAP;
if (isset($driverOptions['context'])) {
$driverOptions['context'] = new Reference($driverOptions['context']);
}
return $driverOptions;
} | php | private function normalizeDriverOptions(array $connection)
{
$driverOptions = $connection['driverOptions'] ?? [];
$driverOptions['typeMap'] = DocumentManager::CLIENT_TYPEMAP;
if (isset($driverOptions['context'])) {
$driverOptions['context'] = new Reference($driverOptions['context']);
}
return $driverOptions;
} | [
"private",
"function",
"normalizeDriverOptions",
"(",
"array",
"$",
"connection",
")",
"{",
"$",
"driverOptions",
"=",
"$",
"connection",
"[",
"'driverOptions'",
"]",
"??",
"[",
"]",
";",
"$",
"driverOptions",
"[",
"'typeMap'",
"]",
"=",
"DocumentManager",
"::... | Normalizes the driver options array
@param array $connection
@return array|null | [
"Normalizes",
"the",
"driver",
"options",
"array"
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/DependencyInjection/DoctrineMongoDBExtension.php#L317-L327 | train |
doctrine/DoctrineMongoDBBundle | DependencyInjection/DoctrineMongoDBExtension.php | DoctrineMongoDBExtension.loadDocumentManagerBundlesMappingInformation | protected function loadDocumentManagerBundlesMappingInformation(array $documentManager, Definition $odmConfigDef, ContainerBuilder $container)
{
// reset state of drivers and alias map. They are only used by this methods and children.
$this->drivers = [];
$this->aliasMap = [];
$this->loadMappingInformation($documentManager, $container);
$this->registerMappingDrivers($documentManager, $container);
if ($odmConfigDef->hasMethodCall('setDocumentNamespaces')) {
// TODO: Can we make a method out of it on Definition? replaceMethodArguments() or something.
$calls = $odmConfigDef->getMethodCalls();
foreach ($calls as $call) {
if ($call[0] !== 'setDocumentNamespaces') {
continue;
}
$this->aliasMap = array_merge($call[1][0], $this->aliasMap);
}
$method = $odmConfigDef->removeMethodCall('setDocumentNamespaces');
}
$odmConfigDef->addMethodCall('setDocumentNamespaces', [$this->aliasMap]);
} | php | protected function loadDocumentManagerBundlesMappingInformation(array $documentManager, Definition $odmConfigDef, ContainerBuilder $container)
{
// reset state of drivers and alias map. They are only used by this methods and children.
$this->drivers = [];
$this->aliasMap = [];
$this->loadMappingInformation($documentManager, $container);
$this->registerMappingDrivers($documentManager, $container);
if ($odmConfigDef->hasMethodCall('setDocumentNamespaces')) {
// TODO: Can we make a method out of it on Definition? replaceMethodArguments() or something.
$calls = $odmConfigDef->getMethodCalls();
foreach ($calls as $call) {
if ($call[0] !== 'setDocumentNamespaces') {
continue;
}
$this->aliasMap = array_merge($call[1][0], $this->aliasMap);
}
$method = $odmConfigDef->removeMethodCall('setDocumentNamespaces');
}
$odmConfigDef->addMethodCall('setDocumentNamespaces', [$this->aliasMap]);
} | [
"protected",
"function",
"loadDocumentManagerBundlesMappingInformation",
"(",
"array",
"$",
"documentManager",
",",
"Definition",
"$",
"odmConfigDef",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// reset state of drivers and alias map. They are only used by this methods a... | Loads an ODM document managers bundle mapping information.
There are two distinct configuration possibilities for mapping information:
1. Specify a bundle and optionally details where the entity and mapping information reside.
2. Specify an arbitrary mapping location.
@param array $documentManager A configured ODM entity manager.
@param Definition $odmConfigDef A Definition instance
@param ContainerBuilder $container A ContainerBuilder instance
@example
doctrine_mongodb:
mappings:
MyBundle1: ~
MyBundle2: xml
MyBundle3: { type: annotation, dir: Documents/ }
MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping }
MyBundle5:
type: xml
dir: [bundle-mappings1/, bundle-mappings2/]
alias: BundleAlias
arbitrary_key:
type: xml
dir: %kernel.dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents
prefix: DoctrineExtensions\Documents\
alias: DExt
In the case of bundles everything is really optional (which leads to autodetection for this bundle) but
in the mappings key everything except alias is a required argument. | [
"Loads",
"an",
"ODM",
"document",
"managers",
"bundle",
"mapping",
"information",
"."
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/DependencyInjection/DoctrineMongoDBExtension.php#L362-L384 | train |
doctrine/DoctrineMongoDBBundle | ManagerConfigurator.php | ManagerConfigurator.enableFilters | private function enableFilters(DocumentManager $documentManager)
{
if (empty($this->enabledFilters)) {
return;
}
$filterCollection = $documentManager->getFilterCollection();
foreach ($this->enabledFilters as $filter) {
$filterCollection->enable($filter);
}
} | php | private function enableFilters(DocumentManager $documentManager)
{
if (empty($this->enabledFilters)) {
return;
}
$filterCollection = $documentManager->getFilterCollection();
foreach ($this->enabledFilters as $filter) {
$filterCollection->enable($filter);
}
} | [
"private",
"function",
"enableFilters",
"(",
"DocumentManager",
"$",
"documentManager",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"enabledFilters",
")",
")",
"{",
"return",
";",
"}",
"$",
"filterCollection",
"=",
"$",
"documentManager",
"->",
"ge... | Enable filters for an given document manager
@return null | [
"Enable",
"filters",
"for",
"an",
"given",
"document",
"manager"
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/ManagerConfigurator.php#L40-L50 | train |
doctrine/DoctrineMongoDBBundle | DependencyInjection/Configuration.php | Configuration.addResolveTargetDocumentsSection | private function addResolveTargetDocumentsSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->fixXmlConfig('resolve_target_document')
->children()
->arrayNode('resolve_target_documents')
->useAttributeAsKey('interface')
->prototype('scalar')
->cannotBeEmpty()
->end()
->end()
->end();
} | php | private function addResolveTargetDocumentsSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->fixXmlConfig('resolve_target_document')
->children()
->arrayNode('resolve_target_documents')
->useAttributeAsKey('interface')
->prototype('scalar')
->cannotBeEmpty()
->end()
->end()
->end();
} | [
"private",
"function",
"addResolveTargetDocumentsSection",
"(",
"ArrayNodeDefinition",
"$",
"rootNode",
")",
"{",
"$",
"rootNode",
"->",
"fixXmlConfig",
"(",
"'resolve_target_document'",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'resolve_target_documents... | Adds the "resolve_target_documents" config section. | [
"Adds",
"the",
"resolve_target_documents",
"config",
"section",
"."
] | a896fcf2f50ca8fa253f8d4608192bf50190d8bc | https://github.com/doctrine/DoctrineMongoDBBundle/blob/a896fcf2f50ca8fa253f8d4608192bf50190d8bc/DependencyInjection/Configuration.php#L344-L356 | train |
Superbalist/flysystem-google-cloud-storage | src/GoogleStorageAdapter.php | GoogleStorageAdapter.getOptionsFromConfig | protected function getOptionsFromConfig(Config $config)
{
$options = [];
if ($visibility = $config->get('visibility')) {
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility);
} else {
// if a file is created without an acl, it isn't accessible via the console
// we therefore default to private
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE);
}
if ($metadata = $config->get('metadata')) {
$options['metadata'] = $metadata;
}
return $options;
} | php | protected function getOptionsFromConfig(Config $config)
{
$options = [];
if ($visibility = $config->get('visibility')) {
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility);
} else {
// if a file is created without an acl, it isn't accessible via the console
// we therefore default to private
$options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE);
}
if ($metadata = $config->get('metadata')) {
$options['metadata'] = $metadata;
}
return $options;
} | [
"protected",
"function",
"getOptionsFromConfig",
"(",
"Config",
"$",
"config",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"visibility",
"=",
"$",
"config",
"->",
"get",
"(",
"'visibility'",
")",
")",
"{",
"$",
"options",
"[",
"'prede... | Returns an array of options from the config.
@param Config $config
@return array | [
"Returns",
"an",
"array",
"of",
"options",
"from",
"the",
"config",
"."
] | 97cf8a5c9a9d368260b2791ec130690a1bec0cbd | https://github.com/Superbalist/flysystem-google-cloud-storage/blob/97cf8a5c9a9d368260b2791ec130690a1bec0cbd/src/GoogleStorageAdapter.php#L139-L156 | train |
Superbalist/flysystem-google-cloud-storage | src/GoogleStorageAdapter.php | GoogleStorageAdapter.upload | protected function upload($path, $contents, Config $config)
{
$path = $this->applyPathPrefix($path);
$options = $this->getOptionsFromConfig($config);
$options['name'] = $path;
$object = $this->bucket->upload($contents, $options);
return $this->normaliseObject($object);
} | php | protected function upload($path, $contents, Config $config)
{
$path = $this->applyPathPrefix($path);
$options = $this->getOptionsFromConfig($config);
$options['name'] = $path;
$object = $this->bucket->upload($contents, $options);
return $this->normaliseObject($object);
} | [
"protected",
"function",
"upload",
"(",
"$",
"path",
",",
"$",
"contents",
",",
"Config",
"$",
"config",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions... | Uploads a file to the Google Cloud Storage service.
@param string $path
@param string|resource $contents
@param Config $config
@return array | [
"Uploads",
"a",
"file",
"to",
"the",
"Google",
"Cloud",
"Storage",
"service",
"."
] | 97cf8a5c9a9d368260b2791ec130690a1bec0cbd | https://github.com/Superbalist/flysystem-google-cloud-storage/blob/97cf8a5c9a9d368260b2791ec130690a1bec0cbd/src/GoogleStorageAdapter.php#L167-L177 | train |
Superbalist/flysystem-google-cloud-storage | src/GoogleStorageAdapter.php | GoogleStorageAdapter.normaliseObject | protected function normaliseObject(StorageObject $object)
{
$name = $this->removePathPrefix($object->name());
$info = $object->info();
$isDir = substr($name, -1) === '/';
if ($isDir) {
$name = rtrim($name, '/');
}
return [
'type' => $isDir ? 'dir' : 'file',
'dirname' => Util::dirname($name),
'path' => $name,
'timestamp' => strtotime($info['updated']),
'mimetype' => isset($info['contentType']) ? $info['contentType'] : '',
'size' => $info['size'],
];
} | php | protected function normaliseObject(StorageObject $object)
{
$name = $this->removePathPrefix($object->name());
$info = $object->info();
$isDir = substr($name, -1) === '/';
if ($isDir) {
$name = rtrim($name, '/');
}
return [
'type' => $isDir ? 'dir' : 'file',
'dirname' => Util::dirname($name),
'path' => $name,
'timestamp' => strtotime($info['updated']),
'mimetype' => isset($info['contentType']) ? $info['contentType'] : '',
'size' => $info['size'],
];
} | [
"protected",
"function",
"normaliseObject",
"(",
"StorageObject",
"$",
"object",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"removePathPrefix",
"(",
"$",
"object",
"->",
"name",
"(",
")",
")",
";",
"$",
"info",
"=",
"$",
"object",
"->",
"info",
"("... | Returns a dictionary of object metadata from an object.
@param StorageObject $object
@return array | [
"Returns",
"a",
"dictionary",
"of",
"object",
"metadata",
"from",
"an",
"object",
"."
] | 97cf8a5c9a9d368260b2791ec130690a1bec0cbd | https://github.com/Superbalist/flysystem-google-cloud-storage/blob/97cf8a5c9a9d368260b2791ec130690a1bec0cbd/src/GoogleStorageAdapter.php#L186-L204 | train |
Superbalist/flysystem-google-cloud-storage | src/GoogleStorageAdapter.php | GoogleStorageAdapter.getUrl | public function getUrl($path)
{
$uri = rtrim($this->storageApiUri, '/');
$path = $this->applyPathPrefix($path);
// Only prepend bucket name if no custom storage uri specified
// Default: "https://storage.googleapis.com/{my_bucket}/{path_prefix}"
// Custom: "https://example.com/{path_prefix}"
if ($this->getStorageApiUri() === self::STORAGE_API_URI_DEFAULT) {
$path = $this->bucket->name() . '/' . $path;
}
return $uri . '/' . $path;
} | php | public function getUrl($path)
{
$uri = rtrim($this->storageApiUri, '/');
$path = $this->applyPathPrefix($path);
// Only prepend bucket name if no custom storage uri specified
// Default: "https://storage.googleapis.com/{my_bucket}/{path_prefix}"
// Custom: "https://example.com/{path_prefix}"
if ($this->getStorageApiUri() === self::STORAGE_API_URI_DEFAULT) {
$path = $this->bucket->name() . '/' . $path;
}
return $uri . '/' . $path;
} | [
"public",
"function",
"getUrl",
"(",
"$",
"path",
")",
"{",
"$",
"uri",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"storageApiUri",
",",
"'/'",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"// Only prepend ... | Return a public url to a file.
Note: The file must have `AdapterInterface::VISIBILITY_PUBLIC` visibility.
@param string $path
@return string | [
"Return",
"a",
"public",
"url",
"to",
"a",
"file",
"."
] | 97cf8a5c9a9d368260b2791ec130690a1bec0cbd | https://github.com/Superbalist/flysystem-google-cloud-storage/blob/97cf8a5c9a9d368260b2791ec130690a1bec0cbd/src/GoogleStorageAdapter.php#L425-L438 | train |
Superbalist/flysystem-google-cloud-storage | src/GoogleStorageAdapter.php | GoogleStorageAdapter.getObject | protected function getObject($path)
{
$path = $this->applyPathPrefix($path);
return $this->bucket->object($path);
} | php | protected function getObject($path)
{
$path = $this->applyPathPrefix($path);
return $this->bucket->object($path);
} | [
"protected",
"function",
"getObject",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"bucket",
"->",
"object",
"(",
"$",
"path",
")",
";",
"}"
] | Returns a storage object for the given path.
@param string $path
@return \Google\Cloud\Storage\StorageObject | [
"Returns",
"a",
"storage",
"object",
"for",
"the",
"given",
"path",
"."
] | 97cf8a5c9a9d368260b2791ec130690a1bec0cbd | https://github.com/Superbalist/flysystem-google-cloud-storage/blob/97cf8a5c9a9d368260b2791ec130690a1bec0cbd/src/GoogleStorageAdapter.php#L465-L469 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.getArchive | public function getArchive($archiveId)
{
Validators::validateArchiveId($archiveId);
$archiveData = $this->client->getArchive($archiveId);
return new Archive($archiveData, array( 'client' => $this->client ));
} | php | public function getArchive($archiveId)
{
Validators::validateArchiveId($archiveId);
$archiveData = $this->client->getArchive($archiveId);
return new Archive($archiveData, array( 'client' => $this->client ));
} | [
"public",
"function",
"getArchive",
"(",
"$",
"archiveId",
")",
"{",
"Validators",
"::",
"validateArchiveId",
"(",
"$",
"archiveId",
")",
";",
"$",
"archiveData",
"=",
"$",
"this",
"->",
"client",
"->",
"getArchive",
"(",
"$",
"archiveId",
")",
";",
"retur... | Gets an Archive object for the given archive ID.
@param String $archiveId The archive ID.
@throws ArchiveException There is no archive with the specified ID.
@throws InvalidArgumentException The archive ID provided is null or an empty string.
@return Archive The Archive object. | [
"Gets",
"an",
"Archive",
"object",
"for",
"the",
"given",
"archive",
"ID",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L366-L372 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.setArchiveLayout | public function setArchiveLayout($archiveId, $layoutType)
{
Validators::validateArchiveId($archiveId);
Validators::validateLayout($layoutType);
$this->client->setArchiveLayout($archiveId, $layoutType);
} | php | public function setArchiveLayout($archiveId, $layoutType)
{
Validators::validateArchiveId($archiveId);
Validators::validateLayout($layoutType);
$this->client->setArchiveLayout($archiveId, $layoutType);
} | [
"public",
"function",
"setArchiveLayout",
"(",
"$",
"archiveId",
",",
"$",
"layoutType",
")",
"{",
"Validators",
"::",
"validateArchiveId",
"(",
"$",
"archiveId",
")",
";",
"Validators",
"::",
"validateLayout",
"(",
"$",
"layoutType",
")",
";",
"$",
"this",
... | Updates the stream layout in an OpenTok Archive.
@param string $archiveId The OpenTok archive ID.
@param string $layout The connectionId of the connection in a session. | [
"Updates",
"the",
"stream",
"layout",
"in",
"an",
"OpenTok",
"Archive",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L432-L438 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.forceDisconnect | public function forceDisconnect($sessionId, $connectionId)
{
Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
Validators::validateConnectionId($connectionId);
return $this->client->forceDisconnect($sessionId, $connectionId);
} | php | public function forceDisconnect($sessionId, $connectionId)
{
Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
Validators::validateConnectionId($connectionId);
return $this->client->forceDisconnect($sessionId, $connectionId);
} | [
"public",
"function",
"forceDisconnect",
"(",
"$",
"sessionId",
",",
"$",
"connectionId",
")",
"{",
"Validators",
"::",
"validateSessionIdBelongsToKey",
"(",
"$",
"sessionId",
",",
"$",
"this",
"->",
"apiKey",
")",
";",
"Validators",
"::",
"validateConnectionId",
... | Disconnects a specific client from an OpenTok session.
@param string $sessionId The OpenTok session ID that the client is connected to.
@param string $connectionId The connection ID of the connection in the session. | [
"Disconnects",
"a",
"specific",
"client",
"from",
"an",
"OpenTok",
"session",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L472-L478 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.startBroadcast | public function startBroadcast($sessionId, $options=array())
{
// unpack optional arguments (merging with default values) into named variables
// NOTE: although the server can be authoritative about the default value of layout, its
// not preferred to depend on that in the SDK because its then harder to garauntee backwards
// compatibility
$defaults = array(
'layout' => Layout::getBestFit()
);
$options = array_merge($defaults, $options);
list($layout) = array_values($options);
// validate arguments
Validators::validateSessionId($sessionId);
Validators::validateLayout($layout);
// make API call
$broadcastData = $this->client->startBroadcast($sessionId, $options);
return new Broadcast($broadcastData, array( 'client' => $this->client ));
} | php | public function startBroadcast($sessionId, $options=array())
{
// unpack optional arguments (merging with default values) into named variables
// NOTE: although the server can be authoritative about the default value of layout, its
// not preferred to depend on that in the SDK because its then harder to garauntee backwards
// compatibility
$defaults = array(
'layout' => Layout::getBestFit()
);
$options = array_merge($defaults, $options);
list($layout) = array_values($options);
// validate arguments
Validators::validateSessionId($sessionId);
Validators::validateLayout($layout);
// make API call
$broadcastData = $this->client->startBroadcast($sessionId, $options);
return new Broadcast($broadcastData, array( 'client' => $this->client ));
} | [
"public",
"function",
"startBroadcast",
"(",
"$",
"sessionId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// unpack optional arguments (merging with default values) into named variables",
"// NOTE: although the server can be authoritative about the default value of layou... | Starts a live streaming broadcast of an OpenTok session.
@param String $sessionId The session ID of the session to be broadcast.
@param Array $options (Optional) An array with options for the broadcast. This array has
the following properties:
<ul>
<li><code>layout</code> (Layout) — (Optional) An object defining the initial
layout type of the broadcast. If you do not specify an initial layout type,
the broadcast stream uses the Best Fit layout type. For more information, see
<a href="https://tokbox.com/developer/guides/broadcast/live-streaming/#configuring-live-streaming-video-layout">Configuring
Video Layout for the OpenTok live streaming feature</a>.
</li>
</ul>
@return Broadcast An object with properties defining the broadcast. | [
"Starts",
"a",
"live",
"streaming",
"broadcast",
"of",
"an",
"OpenTok",
"session",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L498-L518 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.stopBroadcast | public function stopBroadcast($broadcastId)
{
// validate arguments
Validators::validateBroadcastId($broadcastId);
// make API call
$broadcastData = $this->client->stopBroadcast($broadcastId);
return new Broadcast($broadcastData, array(
'client' => $this->client,
'isStopped' => true
));
} | php | public function stopBroadcast($broadcastId)
{
// validate arguments
Validators::validateBroadcastId($broadcastId);
// make API call
$broadcastData = $this->client->stopBroadcast($broadcastId);
return new Broadcast($broadcastData, array(
'client' => $this->client,
'isStopped' => true
));
} | [
"public",
"function",
"stopBroadcast",
"(",
"$",
"broadcastId",
")",
"{",
"// validate arguments",
"Validators",
"::",
"validateBroadcastId",
"(",
"$",
"broadcastId",
")",
";",
"// make API call",
"$",
"broadcastData",
"=",
"$",
"this",
"->",
"client",
"->",
"stop... | Stops a broadcast.
@param String $broadcastId The ID of the broadcast. | [
"Stops",
"a",
"broadcast",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L525-L536 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.getBroadcast | public function getBroadcast($broadcastId)
{
Validators::validateBroadcastId($broadcastId);
$broadcastData = $this->client->getBroadcast($broadcastId);
return new Broadcast($broadcastData, array( 'client' => $this->client ));
} | php | public function getBroadcast($broadcastId)
{
Validators::validateBroadcastId($broadcastId);
$broadcastData = $this->client->getBroadcast($broadcastId);
return new Broadcast($broadcastData, array( 'client' => $this->client ));
} | [
"public",
"function",
"getBroadcast",
"(",
"$",
"broadcastId",
")",
"{",
"Validators",
"::",
"validateBroadcastId",
"(",
"$",
"broadcastId",
")",
";",
"$",
"broadcastData",
"=",
"$",
"this",
"->",
"client",
"->",
"getBroadcast",
"(",
"$",
"broadcastId",
")",
... | Gets information about an OpenTok broadcast.
@param String $broadcastId The ID of the broadcast.
@return Broadcast An object with properties defining the broadcast. | [
"Gets",
"information",
"about",
"an",
"OpenTok",
"broadcast",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L545-L551 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.getStream | public function getStream($sessionId, $streamId)
{
Validators::validateSessionId($sessionId);
Validators::validateStreamId($streamId);
// make API call
$streamData = $this->client->getStream($sessionId, $streamId);
return new Stream($streamData);
} | php | public function getStream($sessionId, $streamId)
{
Validators::validateSessionId($sessionId);
Validators::validateStreamId($streamId);
// make API call
$streamData = $this->client->getStream($sessionId, $streamId);
return new Stream($streamData);
} | [
"public",
"function",
"getStream",
"(",
"$",
"sessionId",
",",
"$",
"streamId",
")",
"{",
"Validators",
"::",
"validateSessionId",
"(",
"$",
"sessionId",
")",
";",
"Validators",
"::",
"validateStreamId",
"(",
"$",
"streamId",
")",
";",
"// make API call",
"$",... | Gets an Stream object, providing information on a given stream.
@param String $sessionId The session ID for the OpenTok session containing the stream.
@param String $streamId The stream ID.
@return Stream The Stream object. | [
"Gets",
"an",
"Stream",
"object",
"providing",
"information",
"on",
"a",
"given",
"stream",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L643-L652 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/OpenTok.php | OpenTok.listStreams | public function listStreams($sessionId)
{
Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
// make API call
$streamListData = $this->client->listStreams($sessionId);
return new StreamList($streamListData);
} | php | public function listStreams($sessionId)
{
Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
// make API call
$streamListData = $this->client->listStreams($sessionId);
return new StreamList($streamListData);
} | [
"public",
"function",
"listStreams",
"(",
"$",
"sessionId",
")",
"{",
"Validators",
"::",
"validateSessionIdBelongsToKey",
"(",
"$",
"sessionId",
",",
"$",
"this",
"->",
"apiKey",
")",
";",
"// make API call",
"$",
"streamListData",
"=",
"$",
"this",
"->",
"cl... | Returns a StreamList Object for the given session ID.
@param String $sessionId The session ID.
@return StreamList A StreamList object. Call the items() method of the StreamList object
to return an array of Stream objects. | [
"Returns",
"a",
"StreamList",
"Object",
"for",
"the",
"given",
"session",
"ID",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/OpenTok.php#L663-L671 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/ArchiveList.php | ArchiveList.getItems | public function getItems()
{
if (!$this->items) {
$items = array();
foreach($this->data['items'] as $archiveData) {
$items[] = new Archive($archiveData, array( 'client' => $this->client ));
}
$this->items = $items;
}
return $this->items;
} | php | public function getItems()
{
if (!$this->items) {
$items = array();
foreach($this->data['items'] as $archiveData) {
$items[] = new Archive($archiveData, array( 'client' => $this->client ));
}
$this->items = $items;
}
return $this->items;
} | [
"public",
"function",
"getItems",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"items",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"[",
"'items'",
"]",
"as",
"$",
"archiveData",
")",
"{",
... | Returns an array of Archive objects. | [
"Returns",
"an",
"array",
"of",
"Archive",
"objects",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/ArchiveList.php#L78-L88 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/Broadcast.php | Broadcast.stop | public function stop()
{
if ($this->isStopped) {
throw new BroadcastDomainException(
'You cannot stop a broadcast which is already stopped.'
);
}
$broadcastData = $this->client->stopBroadcast($this->data['id']);
try {
Validators::validateBroadcastData($broadcastData);
} catch (InvalidArgumentException $e) {
throw new BroadcastUnexpectedValueException('The broadcast JSON returned after stopping was not valid', null, $e);
}
$this->data = $broadcastData;
return $this;
} | php | public function stop()
{
if ($this->isStopped) {
throw new BroadcastDomainException(
'You cannot stop a broadcast which is already stopped.'
);
}
$broadcastData = $this->client->stopBroadcast($this->data['id']);
try {
Validators::validateBroadcastData($broadcastData);
} catch (InvalidArgumentException $e) {
throw new BroadcastUnexpectedValueException('The broadcast JSON returned after stopping was not valid', null, $e);
}
$this->data = $broadcastData;
return $this;
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isStopped",
")",
"{",
"throw",
"new",
"BroadcastDomainException",
"(",
"'You cannot stop a broadcast which is already stopped.'",
")",
";",
"}",
"$",
"broadcastData",
"=",
"$",
"this",
"... | Stops the broadcast. | [
"Stops",
"the",
"broadcast",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/Broadcast.php#L108-L126 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/StreamList.php | StreamList.getItems | public function getItems()
{
if (!is_array($this->items)) {
$items = array();
foreach ($this->data['items'] as $streamData) {
$items[] = new Stream($streamData);
}
$this->items = $items;
}
return $this->items;
} | php | public function getItems()
{
if (!is_array($this->items)) {
$items = array();
foreach ($this->data['items'] as $streamData) {
$items[] = new Stream($streamData);
}
$this->items = $items;
}
return $this->items;
} | [
"public",
"function",
"getItems",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"[",
"'items'",
"]",
"as",
"$",
"... | Returns an array of Stream objects.
@return array | [
"Returns",
"an",
"array",
"of",
"Stream",
"objects",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/StreamList.php#L38-L48 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/Util/Client.php | Client.createSession | public function createSession($options)
{
$request = new Request('POST', '/session/create');
try {
$response = $this->client->send($request, [
'debug' => $this->isDebug(),
'form_params' => $this->postFieldsForOptions($options)
]);
$sessionXml = $this->getResponseXml($response);
} catch (\RuntimeException $e) {
// TODO: test if we have a parse exception and handle it, otherwise throw again
throw $e;
} catch (\Exception $e) {
$this->handleException($e);
return;
}
return $sessionXml;
} | php | public function createSession($options)
{
$request = new Request('POST', '/session/create');
try {
$response = $this->client->send($request, [
'debug' => $this->isDebug(),
'form_params' => $this->postFieldsForOptions($options)
]);
$sessionXml = $this->getResponseXml($response);
} catch (\RuntimeException $e) {
// TODO: test if we have a parse exception and handle it, otherwise throw again
throw $e;
} catch (\Exception $e) {
$this->handleException($e);
return;
}
return $sessionXml;
} | [
"public",
"function",
"createSession",
"(",
"$",
"options",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"'POST'",
",",
"'/session/create'",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"requ... | General API Requests | [
"General",
"API",
"Requests"
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/Util/Client.php#L103-L120 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/Util/Client.php | Client.startArchive | public function startArchive($sessionId, $options)
{
// set up the request
$request = new Request('POST', '/v2/project/'.$this->apiKey.'/archive');
try {
$response = $this->client->send($request, [
'debug' => $this->isDebug(),
'json' => array_merge(
array( 'sessionId' => $sessionId ),
$options
)
]);
$archiveJson = json_decode($response->getBody(), true);
} catch (\Exception $e) {
$this->handleArchiveException($e);
}
return $archiveJson;
} | php | public function startArchive($sessionId, $options)
{
// set up the request
$request = new Request('POST', '/v2/project/'.$this->apiKey.'/archive');
try {
$response = $this->client->send($request, [
'debug' => $this->isDebug(),
'json' => array_merge(
array( 'sessionId' => $sessionId ),
$options
)
]);
$archiveJson = json_decode($response->getBody(), true);
} catch (\Exception $e) {
$this->handleArchiveException($e);
}
return $archiveJson;
} | [
"public",
"function",
"startArchive",
"(",
"$",
"sessionId",
",",
"$",
"options",
")",
"{",
"// set up the request",
"$",
"request",
"=",
"new",
"Request",
"(",
"'POST'",
",",
"'/v2/project/'",
".",
"$",
"this",
"->",
"apiKey",
".",
"'/archive'",
")",
";",
... | Archiving API Requests | [
"Archiving",
"API",
"Requests"
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/Util/Client.php#L149-L167 | train |
opentok/OpenTok-PHP-SDK | src/OpenTok/Layout.php | Layout.createCustom | public static function createCustom($options)
{
// unpack optional arguments (merging with default values) into named variables
// NOTE: the default value of stylesheet=null will not pass validation, this essentially
// means that stylesheet is not optional. its still purposely left as part of the
// $options argument so that it can become truly optional in the future.
$defaults = array('stylesheet' => null);
$options = array_merge($defaults, array_intersect_key($options, $defaults));
list($stylesheet) = array_values($options);
// validate arguments
Validators::validateLayoutStylesheet($stylesheet);
return new Layout('custom', $stylesheet);
} | php | public static function createCustom($options)
{
// unpack optional arguments (merging with default values) into named variables
// NOTE: the default value of stylesheet=null will not pass validation, this essentially
// means that stylesheet is not optional. its still purposely left as part of the
// $options argument so that it can become truly optional in the future.
$defaults = array('stylesheet' => null);
$options = array_merge($defaults, array_intersect_key($options, $defaults));
list($stylesheet) = array_values($options);
// validate arguments
Validators::validateLayoutStylesheet($stylesheet);
return new Layout('custom', $stylesheet);
} | [
"public",
"static",
"function",
"createCustom",
"(",
"$",
"options",
")",
"{",
"// unpack optional arguments (merging with default values) into named variables",
"// NOTE: the default value of stylesheet=null will not pass validation, this essentially",
"// means that stylesheet is not o... | Returns a Layout object defining a custom layout type.
@param array $options An array containing one property: <code>$stylesheet<code>,
which is a string containing the stylesheet to be used for the layout. | [
"Returns",
"a",
"Layout",
"object",
"defining",
"a",
"custom",
"layout",
"type",
"."
] | ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d | https://github.com/opentok/OpenTok-PHP-SDK/blob/ebb2c566fd1b09219f23c37fcf6484ca6ae48a3d/src/OpenTok/Layout.php#L84-L98 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Config.php | Nexcessnet_Turpentine_Model_Shim_Mage_Core_Config.unsetEventAreaCache | public function unsetEventAreaCache($area) {
if (version_compare(Mage::getVersion(), '1.11.0', '>=') // enterprise
|| version_compare(Mage::getVersion(), '1.6.0', '>=')) {
// community
unset($this->_eventAreas[$area]);
}
} | php | public function unsetEventAreaCache($area) {
if (version_compare(Mage::getVersion(), '1.11.0', '>=') // enterprise
|| version_compare(Mage::getVersion(), '1.6.0', '>=')) {
// community
unset($this->_eventAreas[$area]);
}
} | [
"public",
"function",
"unsetEventAreaCache",
"(",
"$",
"area",
")",
"{",
"if",
"(",
"version_compare",
"(",
"Mage",
"::",
"getVersion",
"(",
")",
",",
"'1.11.0'",
",",
"'>='",
")",
"// enterprise",
"||",
"version_compare",
"(",
"Mage",
"::",
"getVersion",
"(... | Clears event area cache so that Turpentine can dynamically add new event
observers even after the first event was fired.
@param $area string The config area to clear (e.g. 'global') | [
"Clears",
"event",
"area",
"cache",
"so",
"that",
"Turpentine",
"can",
"dynamically",
"add",
"new",
"event",
"observers",
"even",
"after",
"the",
"first",
"event",
"was",
"fired",
"."
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Config.php#L47-L53 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/App.php | Nexcessnet_Turpentine_Model_Shim_Mage_Core_App.shim_addEventObserver | public function shim_addEventObserver($area, $eventName, $obsName,
$type = null, $class = null, $method = null) {
$eventConfig = new Varien_Simplexml_Config();
$eventConfig->loadDom($this->_shim_getEventDom(
$area, $eventName, $obsName, $type, $class, $method ));
$this->_shim_getConfig()->extend($eventConfig, true);
// this wouldn't work if PHP had a sane object model
$this->_shim_getApp()->_events[$area][$eventName] = null;
/* clear the event area cache because by the time this gets executed all <global> events have already been
cached in Magento EE 1.11 */
$this->_shim_getConfigShim()->unsetEventAreaCache($area);
return $this;
} | php | public function shim_addEventObserver($area, $eventName, $obsName,
$type = null, $class = null, $method = null) {
$eventConfig = new Varien_Simplexml_Config();
$eventConfig->loadDom($this->_shim_getEventDom(
$area, $eventName, $obsName, $type, $class, $method ));
$this->_shim_getConfig()->extend($eventConfig, true);
// this wouldn't work if PHP had a sane object model
$this->_shim_getApp()->_events[$area][$eventName] = null;
/* clear the event area cache because by the time this gets executed all <global> events have already been
cached in Magento EE 1.11 */
$this->_shim_getConfigShim()->unsetEventAreaCache($area);
return $this;
} | [
"public",
"function",
"shim_addEventObserver",
"(",
"$",
"area",
",",
"$",
"eventName",
",",
"$",
"obsName",
",",
"$",
"type",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"eventConfig",
"=",
"new",
"Va... | Adds new observer for specified event
@param string $area (global|admin...)
@param string $eventName name of the event to observe
@param string $obsName name of the observer (as specified in config.xml)
@param string $type (model|singleton)
@param string $class identifier of the observing model class
@param string $method name of the method to call
@return Nexcessnet_Turpentine_Model_Shim_Mage_Core_App | [
"Adds",
"new",
"observer",
"for",
"specified",
"event"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/App.php#L58-L70 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/App.php | Nexcessnet_Turpentine_Model_Shim_Mage_Core_App._shim_getEventDom | protected function _shim_getEventDom($area, $eventName, $obsName,
$type = null, $class = null, $method = null) {
$dom = new DOMDocument('1.0');
$config = $dom->createElement('config');
$observers = $config
->appendChild($dom->createElement($area))
->appendChild($dom->createElement('events'))
->appendChild($dom->createElement($eventName))
->appendChild($dom->createElement('observers'));
$observer = $dom->createElement($obsName);
if ($class && $method) {
if ($type) {
$observer->appendChild($dom->createElement('type', $type));
}
$observer->appendChild($dom->createElement('class', $class));
$observer->appendChild($dom->createElement('method', $method));
}
$observers->appendChild($observer);
$dom->appendChild($config);
return $dom;
} | php | protected function _shim_getEventDom($area, $eventName, $obsName,
$type = null, $class = null, $method = null) {
$dom = new DOMDocument('1.0');
$config = $dom->createElement('config');
$observers = $config
->appendChild($dom->createElement($area))
->appendChild($dom->createElement('events'))
->appendChild($dom->createElement($eventName))
->appendChild($dom->createElement('observers'));
$observer = $dom->createElement($obsName);
if ($class && $method) {
if ($type) {
$observer->appendChild($dom->createElement('type', $type));
}
$observer->appendChild($dom->createElement('class', $class));
$observer->appendChild($dom->createElement('method', $method));
}
$observers->appendChild($observer);
$dom->appendChild($config);
return $dom;
} | [
"protected",
"function",
"_shim_getEventDom",
"(",
"$",
"area",
",",
"$",
"eventName",
",",
"$",
"obsName",
",",
"$",
"type",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"dom",
"=",
"new",
"DOMDocument... | Prepares event DOM node used for updating configuration
@param string $area (global|admin...)
@param string $eventName
@param string $obsName
@param string $type
@param string $class
@param string $method
@return DOMDocument | [
"Prepares",
"event",
"DOM",
"node",
"used",
"for",
"updating",
"configuration"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/App.php#L103-L123 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Version3.generate | public function generate($doClean = true) {
// first, check if a custom template is set
$customTemplate = $this->_getCustomTemplateFilename();
if ($customTemplate) {
$tplFile = $customTemplate;
} else {
$tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
}
$vcl = $this->_formatTemplate(file_get_contents($tplFile),
$this->_getTemplateVars());
return $doClean ? $this->_cleanVcl($vcl) : $vcl;
} | php | public function generate($doClean = true) {
// first, check if a custom template is set
$customTemplate = $this->_getCustomTemplateFilename();
if ($customTemplate) {
$tplFile = $customTemplate;
} else {
$tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
}
$vcl = $this->_formatTemplate(file_get_contents($tplFile),
$this->_getTemplateVars());
return $doClean ? $this->_cleanVcl($vcl) : $vcl;
} | [
"public",
"function",
"generate",
"(",
"$",
"doClean",
"=",
"true",
")",
"{",
"// first, check if a custom template is set",
"$",
"customTemplate",
"=",
"$",
"this",
"->",
"_getCustomTemplateFilename",
"(",
")",
";",
"if",
"(",
"$",
"customTemplate",
")",
"{",
"... | Generate the Varnish 3.0-compatible VCL
@param bool $doClean if true, VCL will be cleaned (whitespaces stripped, etc.)
@return string | [
"Generate",
"the",
"Varnish",
"3",
".",
"0",
"-",
"compatible",
"VCL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php#L35-L46 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php | Nexcessnet_Turpentine_Helper_Varnish.getSocket | public function getSocket($host, $port, $secretKey = null, $version = null) {
$socket = Mage::getModel('turpentine/varnish_admin_socket',
array('host' => $host, 'port' => $port));
if ($secretKey) {
$socket->setAuthSecret($secretKey);
}
if ($version) {
$socket->setVersion($version);
}
return $socket;
} | php | public function getSocket($host, $port, $secretKey = null, $version = null) {
$socket = Mage::getModel('turpentine/varnish_admin_socket',
array('host' => $host, 'port' => $port));
if ($secretKey) {
$socket->setAuthSecret($secretKey);
}
if ($version) {
$socket->setVersion($version);
}
return $socket;
} | [
"public",
"function",
"getSocket",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"secretKey",
"=",
"null",
",",
"$",
"version",
"=",
"null",
")",
"{",
"$",
"socket",
"=",
"Mage",
"::",
"getModel",
"(",
"'turpentine/varnish_admin_socket'",
",",
"array",
"... | Get a Varnish management socket
@param string $host [description]
@param string|int $port [description]
@param string $secretKey [description]
@param string $version [description]
@return Nexcessnet_Turpentine_Model_Varnish_Admin_Socket | [
"Get",
"a",
"Varnish",
"management",
"socket"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php#L96-L106 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php | Nexcessnet_Turpentine_Helper_Varnish.getSockets | public function getSockets() {
$sockets = array();
$servers = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_varnish/servers/server_list'));
$key = str_replace('\n', PHP_EOL,
Mage::getStoreConfig('turpentine_varnish/servers/auth_key'));
$version = Mage::getStoreConfig('turpentine_varnish/servers/version');
if ($version == 'auto') {
$version = null;
}
foreach ($servers as $server) {
$parts = explode(':', $server);
$sockets[] = $this->getSocket($parts[0], $parts[1], $key, $version);
}
return $sockets;
} | php | public function getSockets() {
$sockets = array();
$servers = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_varnish/servers/server_list'));
$key = str_replace('\n', PHP_EOL,
Mage::getStoreConfig('turpentine_varnish/servers/auth_key'));
$version = Mage::getStoreConfig('turpentine_varnish/servers/version');
if ($version == 'auto') {
$version = null;
}
foreach ($servers as $server) {
$parts = explode(':', $server);
$sockets[] = $this->getSocket($parts[0], $parts[1], $key, $version);
}
return $sockets;
} | [
"public",
"function",
"getSockets",
"(",
")",
"{",
"$",
"sockets",
"=",
"array",
"(",
")",
";",
"$",
"servers",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/data'",
")",
"->",
"cleanExplode",
"(",
"PHP_EOL",
",",
"Mage",
"::",
"getStoreConfig",
"(",
"'... | Get management sockets for all the configured Varnish servers
@return array | [
"Get",
"management",
"sockets",
"for",
"all",
"the",
"configured",
"Varnish",
"servers"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php#L113-L128 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php | Nexcessnet_Turpentine_Helper_Varnish.isBypassEnabled | public function isBypassEnabled() {
$cookieName = Mage::helper('turpentine/data')->getBypassCookieName();
$cookieValue = Mage::getModel('core/cookie')->get($cookieName);
return $cookieValue === $this->getSecretHandshake();
} | php | public function isBypassEnabled() {
$cookieName = Mage::helper('turpentine/data')->getBypassCookieName();
$cookieValue = Mage::getModel('core/cookie')->get($cookieName);
return $cookieValue === $this->getSecretHandshake();
} | [
"public",
"function",
"isBypassEnabled",
"(",
")",
"{",
"$",
"cookieName",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/data'",
")",
"->",
"getBypassCookieName",
"(",
")",
";",
"$",
"cookieValue",
"=",
"Mage",
"::",
"getModel",
"(",
"'core/cookie'",
")",
"... | Check if the Varnish bypass is enabled
@return boolean | [
"Check",
"if",
"the",
"Varnish",
"bypass",
"is",
"enabled"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php#L164-L169 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data.generateUuid | public function generateUuid() {
if (is_readable(self::UUID_SOURCE)) {
$uuid = trim(file_get_contents(self::UUID_SOURCE));
} elseif (function_exists('mt_rand')) {
/**
* Taken from stackoverflow answer, possibly not the fastest or
* strictly standards compliant
* @link http://stackoverflow.com/a/2040279
*/
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
} else {
// chosen by dice roll, guaranteed to be random
$uuid = '4';
}
return $uuid;
} | php | public function generateUuid() {
if (is_readable(self::UUID_SOURCE)) {
$uuid = trim(file_get_contents(self::UUID_SOURCE));
} elseif (function_exists('mt_rand')) {
/**
* Taken from stackoverflow answer, possibly not the fastest or
* strictly standards compliant
* @link http://stackoverflow.com/a/2040279
*/
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
} else {
// chosen by dice roll, guaranteed to be random
$uuid = '4';
}
return $uuid;
} | [
"public",
"function",
"generateUuid",
"(",
")",
"{",
"if",
"(",
"is_readable",
"(",
"self",
"::",
"UUID_SOURCE",
")",
")",
"{",
"$",
"uuid",
"=",
"trim",
"(",
"file_get_contents",
"(",
"self",
"::",
"UUID_SOURCE",
")",
")",
";",
"}",
"elseif",
"(",
"fu... | Generate a v4 UUID
@return string | [
"Generate",
"a",
"v4",
"UUID"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L75-L108 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data.freeze | public function freeze($data) {
Varien_Profiler::start('turpentine::helper::data::freeze');
$frozenData = $this->urlBase64Encode(
$this->_getCrypt()->encrypt(
gzdeflate(
serialize($data),
self::COMPRESSION_LEVEL ) ) );
Varien_Profiler::stop('turpentine::helper::data::freeze');
return $frozenData;
} | php | public function freeze($data) {
Varien_Profiler::start('turpentine::helper::data::freeze');
$frozenData = $this->urlBase64Encode(
$this->_getCrypt()->encrypt(
gzdeflate(
serialize($data),
self::COMPRESSION_LEVEL ) ) );
Varien_Profiler::stop('turpentine::helper::data::freeze');
return $frozenData;
} | [
"public",
"function",
"freeze",
"(",
"$",
"data",
")",
"{",
"Varien_Profiler",
"::",
"start",
"(",
"'turpentine::helper::data::freeze'",
")",
";",
"$",
"frozenData",
"=",
"$",
"this",
"->",
"urlBase64Encode",
"(",
"$",
"this",
"->",
"_getCrypt",
"(",
")",
"-... | Serialize a variable into a string that can be used in a URL
Using gzdeflate to avoid the checksum/metadata overhead in gzencode and
gzcompress
@param mixed $data
@return string | [
"Serialize",
"a",
"variable",
"into",
"a",
"string",
"that",
"can",
"be",
"used",
"in",
"a",
"URL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L160-L169 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data.secureHash | public function secureHash($data) {
$salt = $this->_getCryptKey();
return hash(self::HASH_ALGORITHM, sprintf('%s:%s', $salt, $data));
} | php | public function secureHash($data) {
$salt = $this->_getCryptKey();
return hash(self::HASH_ALGORITHM, sprintf('%s:%s', $salt, $data));
} | [
"public",
"function",
"secureHash",
"(",
"$",
"data",
")",
"{",
"$",
"salt",
"=",
"$",
"this",
"->",
"_getCryptKey",
"(",
")",
";",
"return",
"hash",
"(",
"self",
"::",
"HASH_ALGORITHM",
",",
"sprintf",
"(",
"'%s:%s'",
",",
"$",
"salt",
",",
"$",
"da... | Get SHA256 hash of a string, salted with encryption key
@param string $data
@return string | [
"Get",
"SHA256",
"hash",
"of",
"a",
"string",
"salted",
"with",
"encryption",
"key"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L193-L196 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data.getModelName | public function getModelName($model) {
if (is_object($model)) {
$model = get_class($model);
}
// This guess may work if the extension uses its lowercased name as model group name.
$result = strtolower(preg_replace(
'~^[^_]+_([^_]+)_Model_(.+)$~', '$1/$2', $model ));
// This check is not expensive because the answer should come from Magento's classNameCache
$checkModel = Mage::getConfig()->getModelClassName($result);
if ('Mage_' == substr($checkModel, 0, 5) && ! class_exists($result)) {
// Fallback to full model name.
$result = $model;
}
return $result;
} | php | public function getModelName($model) {
if (is_object($model)) {
$model = get_class($model);
}
// This guess may work if the extension uses its lowercased name as model group name.
$result = strtolower(preg_replace(
'~^[^_]+_([^_]+)_Model_(.+)$~', '$1/$2', $model ));
// This check is not expensive because the answer should come from Magento's classNameCache
$checkModel = Mage::getConfig()->getModelClassName($result);
if ('Mage_' == substr($checkModel, 0, 5) && ! class_exists($result)) {
// Fallback to full model name.
$result = $model;
}
return $result;
} | [
"public",
"function",
"getModelName",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"model",
")",
")",
"{",
"$",
"model",
"=",
"get_class",
"(",
"$",
"model",
")",
";",
"}",
"// This guess may work if the extension uses its lowercased name as mo... | Get the getModel formatted name of a model classname or object
@param string|object $model
@return string | [
"Get",
"the",
"getModel",
"formatted",
"name",
"of",
"a",
"model",
"classname",
"or",
"object"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L234-L248 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data.shouldStripVclWhitespace | public function shouldStripVclWhitespace($action) {
$configValue = $this->getStripVclWhitespace();
if ($configValue === 'always') {
return true;
} elseif ($configValue === 'apply' && $action === 'apply') {
return true;
}
return false;
} | php | public function shouldStripVclWhitespace($action) {
$configValue = $this->getStripVclWhitespace();
if ($configValue === 'always') {
return true;
} elseif ($configValue === 'apply' && $action === 'apply') {
return true;
}
return false;
} | [
"public",
"function",
"shouldStripVclWhitespace",
"(",
"$",
"action",
")",
"{",
"$",
"configValue",
"=",
"$",
"this",
"->",
"getStripVclWhitespace",
"(",
")",
";",
"if",
"(",
"$",
"configValue",
"===",
"'always'",
")",
"{",
"return",
"true",
";",
"}",
"els... | Check if VCL whitespaces should be stripped for the given action
@param string $action can be either "apply", "save" or "download"
@return bool | [
"Check",
"if",
"VCL",
"whitespaces",
"should",
"be",
"stripped",
"for",
"the",
"given",
"action"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L307-L315 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data._getChildBlockNames | protected function _getChildBlockNames($blockNode) {
Varien_Profiler::start('turpentine::helper::data::_getChildBlockNames');
if ($blockNode instanceof Mage_Core_Model_Layout_Element) {
$blockNames = array((string) $blockNode['name']);
foreach ($blockNode->xpath('./block | ./reference') as $childBlockNode) {
$blockNames = array_merge($blockNames,
$this->_getChildBlockNames($childBlockNode));
if ($this->getLayout() instanceof Varien_Simplexml_Config) {
foreach ($this->getLayout()->getNode()->xpath(sprintf(
'//reference[@name=\'%s\']', (string) $childBlockNode['name'] ))
as $childBlockLayoutNode) {
$blockNames = array_merge($blockNames,
$this->_getChildBlockNames($childBlockLayoutNode));
}
}
}
} else {
$blockNames = array();
}
Varien_Profiler::stop('turpentine::helper::data::_getChildBlockNames');
return $blockNames;
} | php | protected function _getChildBlockNames($blockNode) {
Varien_Profiler::start('turpentine::helper::data::_getChildBlockNames');
if ($blockNode instanceof Mage_Core_Model_Layout_Element) {
$blockNames = array((string) $blockNode['name']);
foreach ($blockNode->xpath('./block | ./reference') as $childBlockNode) {
$blockNames = array_merge($blockNames,
$this->_getChildBlockNames($childBlockNode));
if ($this->getLayout() instanceof Varien_Simplexml_Config) {
foreach ($this->getLayout()->getNode()->xpath(sprintf(
'//reference[@name=\'%s\']', (string) $childBlockNode['name'] ))
as $childBlockLayoutNode) {
$blockNames = array_merge($blockNames,
$this->_getChildBlockNames($childBlockLayoutNode));
}
}
}
} else {
$blockNames = array();
}
Varien_Profiler::stop('turpentine::helper::data::_getChildBlockNames');
return $blockNames;
} | [
"protected",
"function",
"_getChildBlockNames",
"(",
"$",
"blockNode",
")",
"{",
"Varien_Profiler",
"::",
"start",
"(",
"'turpentine::helper::data::_getChildBlockNames'",
")",
";",
"if",
"(",
"$",
"blockNode",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"$... | The actual recursive implementation of getChildBlockNames
@param Mage_Core_Model_Layout_Element $blockNode
@return array | [
"The",
"actual",
"recursive",
"implementation",
"of",
"getChildBlockNames"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L332-L354 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Helper/Data.php | Nexcessnet_Turpentine_Helper_Data._getCrypt | protected function _getCrypt() {
if (is_null($this->_crypt)) {
$this->_crypt = Varien_Crypt::factory()
->init($this->_getCryptKey());
}
return $this->_crypt;
} | php | protected function _getCrypt() {
if (is_null($this->_crypt)) {
$this->_crypt = Varien_Crypt::factory()
->init($this->_getCryptKey());
}
return $this->_crypt;
} | [
"protected",
"function",
"_getCrypt",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_crypt",
")",
")",
"{",
"$",
"this",
"->",
"_crypt",
"=",
"Varien_Crypt",
"::",
"factory",
"(",
")",
"->",
"init",
"(",
"$",
"this",
"->",
"_getCryptK... | Get encryption singleton thing
Not using core/cryption because it auto-base64 encodes stuff which we
don't want in this case
@return Mage_Core_Model_Encryption | [
"Get",
"encryption",
"singleton",
"thing"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Data.php#L364-L370 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract.getFromSocket | static public function getFromSocket($socket) {
try {
$version = $socket->getVersion();
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('core/session')
->addError('Error determining Varnish version: '.
$e->getMessage());
return null;
}
switch ($version) {
case '4.0':
case '4.1':
return Mage::getModel(
'turpentine/varnish_configurator_version4',
array('socket' => $socket) );
case '3.0':
return Mage::getModel(
'turpentine/varnish_configurator_version3',
array('socket' => $socket) );
case '2.1':
return Mage::getModel(
'turpentine/varnish_configurator_version2',
array('socket' => $socket) );
default:
Mage::throwException('Unsupported Varnish version');
}
} | php | static public function getFromSocket($socket) {
try {
$version = $socket->getVersion();
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('core/session')
->addError('Error determining Varnish version: '.
$e->getMessage());
return null;
}
switch ($version) {
case '4.0':
case '4.1':
return Mage::getModel(
'turpentine/varnish_configurator_version4',
array('socket' => $socket) );
case '3.0':
return Mage::getModel(
'turpentine/varnish_configurator_version3',
array('socket' => $socket) );
case '2.1':
return Mage::getModel(
'turpentine/varnish_configurator_version2',
array('socket' => $socket) );
default:
Mage::throwException('Unsupported Varnish version');
}
} | [
"static",
"public",
"function",
"getFromSocket",
"(",
"$",
"socket",
")",
"{",
"try",
"{",
"$",
"version",
"=",
"$",
"socket",
"->",
"getVersion",
"(",
")",
";",
"}",
"catch",
"(",
"Mage_Core_Exception",
"$",
"e",
")",
"{",
"Mage",
"::",
"getSingleton",
... | Get the correct version of a configurator from a socket
@param Nexcessnet_Turpentine_Model_Varnish_Admin_Socket $socket
@return Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract | [
"Get",
"the",
"correct",
"version",
"of",
"a",
"configurator",
"from",
"a",
"socket"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L32-L59 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract.save | public function save($generatedConfig) {
$filename = $this->_getVclFilename();
$dir = dirname($filename);
if ( ! is_dir($dir)) {
// this umask is probably redundant, but just in case...
if ( ! mkdir($dir, 0777 & ~umask(), true)) {
$err = error_get_last();
return array(false, $err);
}
}
if (strlen($generatedConfig) !==
file_put_contents($filename, $generatedConfig)) {
$err = error_get_last();
return array(false, $err);
}
return array(true, null);
} | php | public function save($generatedConfig) {
$filename = $this->_getVclFilename();
$dir = dirname($filename);
if ( ! is_dir($dir)) {
// this umask is probably redundant, but just in case...
if ( ! mkdir($dir, 0777 & ~umask(), true)) {
$err = error_get_last();
return array(false, $err);
}
}
if (strlen($generatedConfig) !==
file_put_contents($filename, $generatedConfig)) {
$err = error_get_last();
return array(false, $err);
}
return array(true, null);
} | [
"public",
"function",
"save",
"(",
"$",
"generatedConfig",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"_getVclFilename",
"(",
")",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
"... | Save the generated config to the file specified in Magento config
@param string $generatedConfig config generated by @generate
@return null | [
"Save",
"the",
"generated",
"config",
"to",
"the",
"file",
"specified",
"in",
"Magento",
"config"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L89-L105 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getCustomIncludeFilename | protected function _getCustomIncludeFilename($position = '') {
$key = 'custom_include_file';
$key .= ($position) ? '_'.$position : '';
return $this->_formatTemplate(
Mage::getStoreConfig('turpentine_varnish/servers/'.$key),
array('root_dir' => Mage::getBaseDir()) );
} | php | protected function _getCustomIncludeFilename($position = '') {
$key = 'custom_include_file';
$key .= ($position) ? '_'.$position : '';
return $this->_formatTemplate(
Mage::getStoreConfig('turpentine_varnish/servers/'.$key),
array('root_dir' => Mage::getBaseDir()) );
} | [
"protected",
"function",
"_getCustomIncludeFilename",
"(",
"$",
"position",
"=",
"''",
")",
"{",
"$",
"key",
"=",
"'custom_include_file'",
";",
"$",
"key",
".=",
"(",
"$",
"position",
")",
"?",
"'_'",
".",
"$",
"position",
":",
"''",
";",
"return",
"$",
... | Get the name of the custom include VCL file
@return string | [
"Get",
"the",
"name",
"of",
"the",
"custom",
"include",
"VCL",
"file"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L134-L140 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getCustomTemplateFilename | protected function _getCustomTemplateFilename() {
$filePath = $this->_formatTemplate(
Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'),
array('root_dir' => Mage::getBaseDir())
);
if (is_file($filePath)) { return $filePath; } else { return null; }
} | php | protected function _getCustomTemplateFilename() {
$filePath = $this->_formatTemplate(
Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'),
array('root_dir' => Mage::getBaseDir())
);
if (is_file($filePath)) { return $filePath; } else { return null; }
} | [
"protected",
"function",
"_getCustomTemplateFilename",
"(",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"_formatTemplate",
"(",
"Mage",
"::",
"getStoreConfig",
"(",
"'turpentine_varnish/servers/custom_vcl_template'",
")",
",",
"array",
"(",
"'root_dir'",
"=>",
... | Get the custom VCL template, if it exists
Returns 'null' if the file doesn't exist
@return string | [
"Get",
"the",
"custom",
"VCL",
"template",
"if",
"it",
"exists",
"Returns",
"null",
"if",
"the",
"file",
"doesn",
"t",
"exist"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L149-L155 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getAdminFrontname | protected function _getAdminFrontname() {
if (Mage::getStoreConfig('admin/url/use_custom_path')) {
if (Mage::getStoreConfig('web/url/use_store')) {
return Mage::getModel('core/store')->load(0)->getCode()."/".Mage::getStoreConfig('admin/url/custom_path');
} else {
return Mage::getStoreConfig('admin/url/custom_path');
}
} else {
return (string) Mage::getConfig()->getNode(
'admin/routers/adminhtml/args/frontName' );
}
} | php | protected function _getAdminFrontname() {
if (Mage::getStoreConfig('admin/url/use_custom_path')) {
if (Mage::getStoreConfig('web/url/use_store')) {
return Mage::getModel('core/store')->load(0)->getCode()."/".Mage::getStoreConfig('admin/url/custom_path');
} else {
return Mage::getStoreConfig('admin/url/custom_path');
}
} else {
return (string) Mage::getConfig()->getNode(
'admin/routers/adminhtml/args/frontName' );
}
} | [
"protected",
"function",
"_getAdminFrontname",
"(",
")",
"{",
"if",
"(",
"Mage",
"::",
"getStoreConfig",
"(",
"'admin/url/use_custom_path'",
")",
")",
"{",
"if",
"(",
"Mage",
"::",
"getStoreConfig",
"(",
"'web/url/use_store'",
")",
")",
"{",
"return",
"Mage",
... | Get the Magento admin frontname
This is just the plain string, not in URL format. ex:
http://example.com/magento/admin -> admin
@return string | [
"Get",
"the",
"Magento",
"admin",
"frontname"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L193-L204 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getNormalizeHostTarget | protected function _getNormalizeHostTarget() {
$configHost = trim(Mage::getStoreConfig(
'turpentine_vcl/normalization/host_target' ));
if ($configHost) {
return $configHost;
} else {
$baseUrl = parse_url(Mage::getBaseUrl());
if (isset($baseUrl['port'])) {
return sprintf('%s:%d', $baseUrl['host'], $baseUrl['port']);
} else {
return $baseUrl['host'];
}
}
} | php | protected function _getNormalizeHostTarget() {
$configHost = trim(Mage::getStoreConfig(
'turpentine_vcl/normalization/host_target' ));
if ($configHost) {
return $configHost;
} else {
$baseUrl = parse_url(Mage::getBaseUrl());
if (isset($baseUrl['port'])) {
return sprintf('%s:%d', $baseUrl['host'], $baseUrl['port']);
} else {
return $baseUrl['host'];
}
}
} | [
"protected",
"function",
"_getNormalizeHostTarget",
"(",
")",
"{",
"$",
"configHost",
"=",
"trim",
"(",
"Mage",
"::",
"getStoreConfig",
"(",
"'turpentine_vcl/normalization/host_target'",
")",
")",
";",
"if",
"(",
"$",
"configHost",
")",
"{",
"return",
"$",
"conf... | Get the hostname for host normalization from Magento's base URL
@return string | [
"Get",
"the",
"hostname",
"for",
"host",
"normalization",
"from",
"Magento",
"s",
"base",
"URL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L211-L224 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract.getAllowedHostsRegex | public function getAllowedHostsRegex() {
$hosts = array();
foreach (Mage::app()->getStores() as $store) {
$hosts[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false), PHP_URL_HOST);
}
$hosts = array_values(array_unique($hosts));
$pattern = '('.implode('|', array_map("preg_quote", $hosts)).')';
return $pattern;
} | php | public function getAllowedHostsRegex() {
$hosts = array();
foreach (Mage::app()->getStores() as $store) {
$hosts[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false), PHP_URL_HOST);
}
$hosts = array_values(array_unique($hosts));
$pattern = '('.implode('|', array_map("preg_quote", $hosts)).')';
return $pattern;
} | [
"public",
"function",
"getAllowedHostsRegex",
"(",
")",
"{",
"$",
"hosts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStores",
"(",
")",
"as",
"$",
"store",
")",
"{",
"$",
"hosts",
"[",
"]",
"=",
"parse_ur... | Get hosts as regex
ex: base_url: example.com
path_regex: (example.com|example.net)
@return string | [
"Get",
"hosts",
"as",
"regex"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L234-L244 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getBaseUrlPaths | protected function _getBaseUrlPaths() {
$paths = array();
$linkTypes = array(Mage_Core_Model_Store::URL_TYPE_LINK,
Mage_Core_Model_Store::URL_TYPE_JS,
Mage_Core_Model_Store::URL_TYPE_SKIN,
Mage_Core_Model_Store::URL_TYPE_MEDIA);
foreach (Mage::app()->getStores() as $store) {
foreach ($linkTypes as $linkType) {
$paths[] = parse_url($store->getBaseUrl($linkType, false),
PHP_URL_PATH);
$paths[] = parse_url($store->getBaseUrl($linkType, true),
PHP_URL_PATH);
}
}
$paths = array_unique($paths);
usort($paths, create_function('$a, $b',
'return strlen( $b ) - strlen( $a );'));
return array_values($paths);
} | php | protected function _getBaseUrlPaths() {
$paths = array();
$linkTypes = array(Mage_Core_Model_Store::URL_TYPE_LINK,
Mage_Core_Model_Store::URL_TYPE_JS,
Mage_Core_Model_Store::URL_TYPE_SKIN,
Mage_Core_Model_Store::URL_TYPE_MEDIA);
foreach (Mage::app()->getStores() as $store) {
foreach ($linkTypes as $linkType) {
$paths[] = parse_url($store->getBaseUrl($linkType, false),
PHP_URL_PATH);
$paths[] = parse_url($store->getBaseUrl($linkType, true),
PHP_URL_PATH);
}
}
$paths = array_unique($paths);
usort($paths, create_function('$a, $b',
'return strlen( $b ) - strlen( $a );'));
return array_values($paths);
} | [
"protected",
"function",
"_getBaseUrlPaths",
"(",
")",
"{",
"$",
"paths",
"=",
"array",
"(",
")",
";",
"$",
"linkTypes",
"=",
"array",
"(",
"Mage_Core_Model_Store",
"::",
"URL_TYPE_LINK",
",",
"Mage_Core_Model_Store",
"::",
"URL_TYPE_JS",
",",
"Mage_Core_Model_Sto... | Get the path part of each store's base URL and static file URLs
@return array | [
"Get",
"the",
"path",
"part",
"of",
"each",
"store",
"s",
"base",
"URL",
"and",
"static",
"file",
"URLs"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L282-L300 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getUrlExcludes | protected function _getUrlExcludes() {
$urls = Mage::getStoreConfig('turpentine_vcl/urls/url_blacklist');
return implode('|', array_merge(array($this->_getAdminFrontname(), 'api'),
Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, $urls)));
} | php | protected function _getUrlExcludes() {
$urls = Mage::getStoreConfig('turpentine_vcl/urls/url_blacklist');
return implode('|', array_merge(array($this->_getAdminFrontname(), 'api'),
Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, $urls)));
} | [
"protected",
"function",
"_getUrlExcludes",
"(",
")",
"{",
"$",
"urls",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"'turpentine_vcl/urls/url_blacklist'",
")",
";",
"return",
"implode",
"(",
"'|'",
",",
"array_merge",
"(",
"array",
"(",
"$",
"this",
"->",
"_getA... | Format the URL exclusions for insertion in a regex. Admin frontname and
API are automatically added.
@return string | [
"Format",
"the",
"URL",
"exclusions",
"for",
"insertion",
"in",
"a",
"regex",
".",
"Admin",
"frontname",
"and",
"API",
"are",
"automatically",
"added",
"."
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L308-L312 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getDefaultBackend | protected function _getDefaultBackend() {
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/frontend_timeout');
$default_options = array(
'first_byte_timeout' => $timeout.'s',
'between_bytes_timeout' => $timeout.'s',
);
if (Mage::getStoreConfig('turpentine_vcl/backend/load_balancing') != 'no') {
return $this->_vcl_director('default', $default_options);
} else {
return $this->_vcl_backend('default',
Mage::getStoreConfig('turpentine_vcl/backend/backend_host'),
Mage::getStoreConfig('turpentine_vcl/backend/backend_port'),
$default_options);
}
} | php | protected function _getDefaultBackend() {
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/frontend_timeout');
$default_options = array(
'first_byte_timeout' => $timeout.'s',
'between_bytes_timeout' => $timeout.'s',
);
if (Mage::getStoreConfig('turpentine_vcl/backend/load_balancing') != 'no') {
return $this->_vcl_director('default', $default_options);
} else {
return $this->_vcl_backend('default',
Mage::getStoreConfig('turpentine_vcl/backend/backend_host'),
Mage::getStoreConfig('turpentine_vcl/backend/backend_port'),
$default_options);
}
} | [
"protected",
"function",
"_getDefaultBackend",
"(",
")",
"{",
"$",
"timeout",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"'turpentine_vcl/backend/frontend_timeout'",
")",
";",
"$",
"default_options",
"=",
"array",
"(",
"'first_byte_timeout'",
"=>",
"$",
"timeout",
".... | Get the default backend configuration string
@return string | [
"Get",
"the",
"default",
"backend",
"configuration",
"string"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L328-L342 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getAdminBackend | protected function _getAdminBackend() {
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/admin_timeout');
$admin_options = array(
'first_byte_timeout' => $timeout.'s',
'between_bytes_timeout' => $timeout.'s',
);
if (Mage::getStoreConfig('turpentine_vcl/backend/load_balancing') != 'no') {
return $this->_vcl_director('admin', $admin_options);
} else {
return $this->_vcl_backend('admin',
Mage::getStoreConfig('turpentine_vcl/backend/backend_host'),
Mage::getStoreConfig('turpentine_vcl/backend/backend_port'),
$admin_options);
}
} | php | protected function _getAdminBackend() {
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/admin_timeout');
$admin_options = array(
'first_byte_timeout' => $timeout.'s',
'between_bytes_timeout' => $timeout.'s',
);
if (Mage::getStoreConfig('turpentine_vcl/backend/load_balancing') != 'no') {
return $this->_vcl_director('admin', $admin_options);
} else {
return $this->_vcl_backend('admin',
Mage::getStoreConfig('turpentine_vcl/backend/backend_host'),
Mage::getStoreConfig('turpentine_vcl/backend/backend_port'),
$admin_options);
}
} | [
"protected",
"function",
"_getAdminBackend",
"(",
")",
"{",
"$",
"timeout",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"'turpentine_vcl/backend/admin_timeout'",
")",
";",
"$",
"admin_options",
"=",
"array",
"(",
"'first_byte_timeout'",
"=>",
"$",
"timeout",
".",
"'... | Get the admin backend configuration string
@return string | [
"Get",
"the",
"admin",
"backend",
"configuration",
"string"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L349-L363 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getUrlTtls | protected function _getUrlTtls() {
$str = array();
$configTtls = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/ttls/url_ttls'));
$ttls = array();
foreach ($configTtls as $line) {
$ttls[] = explode(',', trim($line));
}
foreach ($ttls as $ttl) {
$str[] = sprintf('if (bereq.url ~ "%s%s") { set beresp.ttl = %ds; }',
$this->getBaseUrlPathRegex(), $ttl[0], $ttl[1]);
}
$str = implode(' else ', $str);
if ($str) {
$str .= sprintf(' else { set beresp.ttl = %ds; }',
$this->_getDefaultTtl());
} else {
$str = sprintf('set beresp.ttl = %ds;', $this->_getDefaultTtl());
}
return $str;
} | php | protected function _getUrlTtls() {
$str = array();
$configTtls = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/ttls/url_ttls'));
$ttls = array();
foreach ($configTtls as $line) {
$ttls[] = explode(',', trim($line));
}
foreach ($ttls as $ttl) {
$str[] = sprintf('if (bereq.url ~ "%s%s") { set beresp.ttl = %ds; }',
$this->getBaseUrlPathRegex(), $ttl[0], $ttl[1]);
}
$str = implode(' else ', $str);
if ($str) {
$str .= sprintf(' else { set beresp.ttl = %ds; }',
$this->_getDefaultTtl());
} else {
$str = sprintf('set beresp.ttl = %ds;', $this->_getDefaultTtl());
}
return $str;
} | [
"protected",
"function",
"_getUrlTtls",
"(",
")",
"{",
"$",
"str",
"=",
"array",
"(",
")",
";",
"$",
"configTtls",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/data'",
")",
"->",
"cleanExplode",
"(",
"PHP_EOL",
",",
"Mage",
"::",
"getStoreConfig",
"(",
... | Format the by-url TTL value list
@return string | [
"Format",
"the",
"by",
"-",
"url",
"TTL",
"value",
"list"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L499-L519 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._getAdvancedSessionValidationTargets | protected function _getAdvancedSessionValidationTargets() {
$validation = array();
if (Mage::getStoreConfig('web/session/use_remote_addr')) {
$validation[] = 'client.ip';
}
if (Mage::getStoreConfig('web/session/use_http_via')) {
$validation[] = 'req.http.Via';
}
if (Mage::getStoreConfig('web/session/use_http_x_forwarded_for')) {
$validation[] = 'req.http.X-Forwarded-For';
}
if (Mage::getStoreConfig(
'web/session/use_http_user_agent' ) &&
! Mage::getStoreConfig(
'turpentine_vcl/normalization/user_agent' )) {
$validation[] = 'req.http.User-Agent';
}
return $validation;
} | php | protected function _getAdvancedSessionValidationTargets() {
$validation = array();
if (Mage::getStoreConfig('web/session/use_remote_addr')) {
$validation[] = 'client.ip';
}
if (Mage::getStoreConfig('web/session/use_http_via')) {
$validation[] = 'req.http.Via';
}
if (Mage::getStoreConfig('web/session/use_http_x_forwarded_for')) {
$validation[] = 'req.http.X-Forwarded-For';
}
if (Mage::getStoreConfig(
'web/session/use_http_user_agent' ) &&
! Mage::getStoreConfig(
'turpentine_vcl/normalization/user_agent' )) {
$validation[] = 'req.http.User-Agent';
}
return $validation;
} | [
"protected",
"function",
"_getAdvancedSessionValidationTargets",
"(",
")",
"{",
"$",
"validation",
"=",
"array",
"(",
")",
";",
"if",
"(",
"Mage",
"::",
"getStoreConfig",
"(",
"'web/session/use_remote_addr'",
")",
")",
"{",
"$",
"validation",
"[",
"]",
"=",
"'... | Get the advanced session validation restrictions
Note that if User-Agent Normalization is on then the normalized user-agent
is used for user-agent validation instead of the full user-agent
@return string | [
"Get",
"the",
"advanced",
"session",
"validation",
"restrictions"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L582-L600 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._cleanVcl | protected function _cleanVcl($dirtyVcl) {
return implode(PHP_EOL,
array_filter(
Mage::helper('turpentine/data')
->cleanExplode(PHP_EOL, $dirtyVcl),
array($this, '_cleanVclHelper')
)
);
} | php | protected function _cleanVcl($dirtyVcl) {
return implode(PHP_EOL,
array_filter(
Mage::helper('turpentine/data')
->cleanExplode(PHP_EOL, $dirtyVcl),
array($this, '_cleanVclHelper')
)
);
} | [
"protected",
"function",
"_cleanVcl",
"(",
"$",
"dirtyVcl",
")",
"{",
"return",
"implode",
"(",
"PHP_EOL",
",",
"array_filter",
"(",
"Mage",
"::",
"helper",
"(",
"'turpentine/data'",
")",
"->",
"cleanExplode",
"(",
"PHP_EOL",
",",
"$",
"dirtyVcl",
")",
",",
... | Remove empty and commented out lines from the generated VCL
@param string $dirtyVcl generated vcl
@return string | [
"Remove",
"empty",
"and",
"commented",
"out",
"lines",
"from",
"the",
"generated",
"VCL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L608-L616 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._vcl_backend | protected function _vcl_backend($name, $host, $port, $options = array()) {
$tpl = <<<EOS
backend {{name}} {
.host = "{{host}}";
.port = "{{port}}";
EOS;
$vars = array(
'host' => $host,
'port' => $port,
'name' => $name,
);
$str = $this->_formatTemplate($tpl, $vars);
foreach ($options as $key => $value) {
$str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL;
}
$str .= '}'.PHP_EOL;
return $str;
} | php | protected function _vcl_backend($name, $host, $port, $options = array()) {
$tpl = <<<EOS
backend {{name}} {
.host = "{{host}}";
.port = "{{port}}";
EOS;
$vars = array(
'host' => $host,
'port' => $port,
'name' => $name,
);
$str = $this->_formatTemplate($tpl, $vars);
foreach ($options as $key => $value) {
$str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL;
}
$str .= '}'.PHP_EOL;
return $str;
} | [
"protected",
"function",
"_vcl_backend",
"(",
"$",
"name",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tpl",
"=",
" <<<EOS\nbackend {{name}} {\n .host = \"{{host}}\";\n .port = \"{{port}}\";\n\nEOS",
";",
... | Format a VCL backend declaration
@param string $name name of the backend
@param string $host backend host
@param string $port backend port
@param array $options options
@return string | [
"Format",
"a",
"VCL",
"backend",
"declaration"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L640-L658 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._vcl_director_backend | protected function _vcl_director_backend($host, $port, $descriptor = '', $probeUrl = '', $options = array()) {
$tpl = <<<EOS
{
.backend {$descriptor} = {
.host = "{{host}}";
.port = "{{port}}";
{{probe}}
EOS;
$vars = array(
'host' => $host,
'port' => $port,
'probe' => ''
);
if ( ! empty($probeUrl)) {
$vars['probe'] = $this->_vcl_get_probe($probeUrl);
}
$str = $this->_formatTemplate($tpl, $vars);
foreach ($options as $key => $value) {
$str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL;
}
$str .= <<<EOS
}
}
EOS;
return $str;
} | php | protected function _vcl_director_backend($host, $port, $descriptor = '', $probeUrl = '', $options = array()) {
$tpl = <<<EOS
{
.backend {$descriptor} = {
.host = "{{host}}";
.port = "{{port}}";
{{probe}}
EOS;
$vars = array(
'host' => $host,
'port' => $port,
'probe' => ''
);
if ( ! empty($probeUrl)) {
$vars['probe'] = $this->_vcl_get_probe($probeUrl);
}
$str = $this->_formatTemplate($tpl, $vars);
foreach ($options as $key => $value) {
$str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL;
}
$str .= <<<EOS
}
}
EOS;
return $str;
} | [
"protected",
"function",
"_vcl_director_backend",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"descriptor",
"=",
"''",
",",
"$",
"probeUrl",
"=",
"''",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tpl",
"=",
" <<<EOS\n {\n .ba... | Format a VCL backend declaration to put inside director
@param string $host backend host
@param string $port backend port
@param string $descriptor backend descriptor
@param string $probeUrl URL to check if backend is up
@param array $options extra options for backend
@return string | [
"Format",
"a",
"VCL",
"backend",
"declaration",
"to",
"put",
"inside",
"director"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L714-L740 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._vcl_get_probe | protected function _vcl_get_probe($probeUrl) {
$urlParts = parse_url($probeUrl);
if (empty($urlParts)) {
// Malformed URL
return '';
} else {
$tpl = <<<EOS
.probe = {
.timeout = {{timeout}};
.interval = {{interval}};
.window = {{window}};
.threshold = {{threshold}};
.request =
"GET {{probe_path}} HTTP/1.1"
"Host: {{probe_host}}"
"Connection: close";
}
EOS;
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_timeout');
$interval = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_interval');
$window = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_window');
$threshold = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_threshold');
return $this->_formatTemplate($tpl, array(
'probe_host' => $urlParts['host'],
'probe_path' => $urlParts['path'],
'timeout' => $timeout,
'interval' => $interval,
'window' => $window,
'threshold' => $threshold,
));
}
} | php | protected function _vcl_get_probe($probeUrl) {
$urlParts = parse_url($probeUrl);
if (empty($urlParts)) {
// Malformed URL
return '';
} else {
$tpl = <<<EOS
.probe = {
.timeout = {{timeout}};
.interval = {{interval}};
.window = {{window}};
.threshold = {{threshold}};
.request =
"GET {{probe_path}} HTTP/1.1"
"Host: {{probe_host}}"
"Connection: close";
}
EOS;
$timeout = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_timeout');
$interval = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_interval');
$window = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_window');
$threshold = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_threshold');
return $this->_formatTemplate($tpl, array(
'probe_host' => $urlParts['host'],
'probe_path' => $urlParts['path'],
'timeout' => $timeout,
'interval' => $interval,
'window' => $window,
'threshold' => $threshold,
));
}
} | [
"protected",
"function",
"_vcl_get_probe",
"(",
"$",
"probeUrl",
")",
"{",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"probeUrl",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"urlParts",
")",
")",
"{",
"// Malformed URL",
"return",
"''",
";",
"}",
"else",
... | Format a VCL probe declaration to put in backend which is in director
@param string $probeUrl URL to check if backend is up
@return string | [
"Format",
"a",
"VCL",
"probe",
"declaration",
"to",
"put",
"in",
"backend",
"which",
"is",
"in",
"director"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L749-L782 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._vcl_acl | protected function _vcl_acl($name, array $hosts) {
$tpl = <<<EOS
acl {{name}} {
{{hosts}}
}
EOS;
$fmtHost = create_function('$h', 'return sprintf(\'"%s";\',$h);');
$vars = array(
'name' => $name,
'hosts' => implode("\n ", array_map($fmtHost, $hosts)),
);
return $this->_formatTemplate($tpl, $vars);
} | php | protected function _vcl_acl($name, array $hosts) {
$tpl = <<<EOS
acl {{name}} {
{{hosts}}
}
EOS;
$fmtHost = create_function('$h', 'return sprintf(\'"%s";\',$h);');
$vars = array(
'name' => $name,
'hosts' => implode("\n ", array_map($fmtHost, $hosts)),
);
return $this->_formatTemplate($tpl, $vars);
} | [
"protected",
"function",
"_vcl_acl",
"(",
"$",
"name",
",",
"array",
"$",
"hosts",
")",
"{",
"$",
"tpl",
"=",
" <<<EOS\nacl {{name}} {\n {{hosts}}\n}\nEOS",
";",
"$",
"fmtHost",
"=",
"create_function",
"(",
"'$h'",
",",
"'return sprintf(\\'\"%s\";\\',$h);'",
")",... | Format a VCL ACL declaration
@param string $name ACL name
@param array $hosts list of hosts to add to the ACL
@return string | [
"Format",
"a",
"VCL",
"ACL",
"declaration"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L791-L803 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract._vcl_sub_synth_https_fix | protected function _vcl_sub_synth_https_fix()
{
$tpl = $this->_vcl_sub_synth();
if ( ! $tpl) {
$tpl = <<<EOS
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://" + req.http.host + req.url;
return(deliver);
}
}
EOS;
} else{
$tpl_750 = '
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://" + req.http.host + req.url;
return(deliver);
}';
$tpl = str_ireplace('sub vcl_synth {', $tpl_750, $tpl);
}
return $tpl;
} | php | protected function _vcl_sub_synth_https_fix()
{
$tpl = $this->_vcl_sub_synth();
if ( ! $tpl) {
$tpl = <<<EOS
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://" + req.http.host + req.url;
return(deliver);
}
}
EOS;
} else{
$tpl_750 = '
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://" + req.http.host + req.url;
return(deliver);
}';
$tpl = str_ireplace('sub vcl_synth {', $tpl_750, $tpl);
}
return $tpl;
} | [
"protected",
"function",
"_vcl_sub_synth_https_fix",
"(",
")",
"{",
"$",
"tpl",
"=",
"$",
"this",
"->",
"_vcl_sub_synth",
"(",
")",
";",
"if",
"(",
"!",
"$",
"tpl",
")",
"{",
"$",
"tpl",
"=",
" <<<EOS\nsub vcl_synth {\n if (resp.status == 750) {\n set re... | vcl_synth for fixing https
@return string | [
"vcl_synth",
"for",
"fixing",
"https"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php#L1048-L1075 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php | Nexcessnet_Turpentine_Model_Varnish_Configurator_Version4._vcl_director | protected function _vcl_director($name, $backendOptions) {
$tpl = <<<EOS
{{backends}}
EOS;
if ('admin' == $name && 'yes_admin' == Mage::getStoreConfig('turpentine_vcl/backend/load_balancing')) {
$backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes_admin'));
$probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url_admin');
$prefix = 'admin';
} else {
$backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
$probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url');
if ('admin' == $name) {
$prefix = 'admin';
} else {
$prefix = '';
}
}
$backends = '';
$number = 0;
foreach ($backendNodes as $backendNode) {
$parts = explode(':', $backendNode, 2);
$host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
$port = (empty($parts[1])) ? '80' : $parts[1];
$backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions);
$number++;
}
$vars = array(
'name' => $name,
'backends' => $backends
);
return $this->_formatTemplate($tpl, $vars);
} | php | protected function _vcl_director($name, $backendOptions) {
$tpl = <<<EOS
{{backends}}
EOS;
if ('admin' == $name && 'yes_admin' == Mage::getStoreConfig('turpentine_vcl/backend/load_balancing')) {
$backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes_admin'));
$probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url_admin');
$prefix = 'admin';
} else {
$backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
$probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url');
if ('admin' == $name) {
$prefix = 'admin';
} else {
$prefix = '';
}
}
$backends = '';
$number = 0;
foreach ($backendNodes as $backendNode) {
$parts = explode(':', $backendNode, 2);
$host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
$port = (empty($parts[1])) ? '80' : $parts[1];
$backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions);
$number++;
}
$vars = array(
'name' => $name,
'backends' => $backends
);
return $this->_formatTemplate($tpl, $vars);
} | [
"protected",
"function",
"_vcl_director",
"(",
"$",
"name",
",",
"$",
"backendOptions",
")",
"{",
"$",
"tpl",
"=",
" <<<EOS\n{{backends}}\nEOS",
";",
"if",
"(",
"'admin'",
"==",
"$",
"name",
"&&",
"'yes_admin'",
"==",
"Mage",
"::",
"getStoreConfig",
"(",
"'t... | Format a VCL director declaration, for load balancing
@param string $name name of the director, also used to select config settings
@param array $backendOptions options for each backend
@return string | [
"Format",
"a",
"VCL",
"director",
"declaration",
"for",
"load",
"balancing"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php#L131-L167 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Layout.php | Nexcessnet_Turpentine_Model_Shim_Mage_Core_Layout.shim_generateFullBlock | public function shim_generateFullBlock($blockNode) {
$layout = $this->_shim_getLayout();
if ( ! ($parent = $blockNode->getParent())) {
$parent = new Varien_Object();
}
$layout->_generateBlock($blockNode, $parent);
return $layout->generateBlocks($blockNode);
} | php | public function shim_generateFullBlock($blockNode) {
$layout = $this->_shim_getLayout();
if ( ! ($parent = $blockNode->getParent())) {
$parent = new Varien_Object();
}
$layout->_generateBlock($blockNode, $parent);
return $layout->generateBlocks($blockNode);
} | [
"public",
"function",
"shim_generateFullBlock",
"(",
"$",
"blockNode",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"_shim_getLayout",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"parent",
"=",
"$",
"blockNode",
"->",
"getParent",
"(",
")",
")",
")",
... | Generate a full block instead of just it's decendents
@param Mage_Core_Model_Layout_Element $blockNode
@return null | [
"Generate",
"a",
"full",
"block",
"instead",
"of",
"just",
"it",
"s",
"decendents"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Layout.php#L29-L36 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Layout.php | Nexcessnet_Turpentine_Model_Shim_Mage_Core_Layout.shim_generateAction | public function shim_generateAction($node) {
if ( ! ($parentNode = $node->getParent())) {
$parentNode = new Varien_Object();
}
return $this->_shim_getLayout()->_generateAction($node, $parentNode);
} | php | public function shim_generateAction($node) {
if ( ! ($parentNode = $node->getParent())) {
$parentNode = new Varien_Object();
}
return $this->_shim_getLayout()->_generateAction($node, $parentNode);
} | [
"public",
"function",
"shim_generateAction",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"parentNode",
"=",
"$",
"node",
"->",
"getParent",
"(",
")",
")",
")",
"{",
"$",
"parentNode",
"=",
"new",
"Varien_Object",
"(",
")",
";",
"}",
"return... | Apply the layout action node for a block
@param Mage_Core_Model_Layout_Element $node
@return Mage_Core_Model_Layout | [
"Apply",
"the",
"layout",
"action",
"node",
"for",
"a",
"block"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Shim/Mage/Core/Layout.php#L44-L49 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.setCustomerGroupCookie | public function setCustomerGroupCookie($eventObject) {
$customer = $eventObject->getCustomer();
$cookie = Mage::getSingleton('core/cookie');
if (Mage::getStoreConfig('persistent/options/enabled')) {
$cookie->set('customer_group', $customer->getGroupId(), Mage::getStoreConfig('persistent/options/lifetime'));
} else {
$cookie->set('customer_group', $customer->getGroupId());
}
} | php | public function setCustomerGroupCookie($eventObject) {
$customer = $eventObject->getCustomer();
$cookie = Mage::getSingleton('core/cookie');
if (Mage::getStoreConfig('persistent/options/enabled')) {
$cookie->set('customer_group', $customer->getGroupId(), Mage::getStoreConfig('persistent/options/lifetime'));
} else {
$cookie->set('customer_group', $customer->getGroupId());
}
} | [
"public",
"function",
"setCustomerGroupCookie",
"(",
"$",
"eventObject",
")",
"{",
"$",
"customer",
"=",
"$",
"eventObject",
"->",
"getCustomer",
"(",
")",
";",
"$",
"cookie",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'core/cookie'",
")",
";",
"if",
"(",
"M... | Set a cookie with the customer group id when customer logs in
Events: customer_login
@param Varien_Object $eventObject
@return null | [
"Set",
"a",
"cookie",
"with",
"the",
"customer",
"group",
"id",
"when",
"customer",
"logs",
"in"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L31-L39 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.setFlagHeaders | public function setFlagHeaders($eventObject) {
$response = $eventObject->getResponse();
if (Mage::helper('turpentine/esi')->shouldResponseUseEsi()) {
$response->setHeader('X-Turpentine-Esi',
Mage::registry('turpentine_esi_flag') ? '1' : '0');
Mage::helper('turpentine/debug')->logDebug(
'Set ESI flag header to: %s',
(Mage::registry('turpentine_esi_flag') ? '1' : '0') );
}
} | php | public function setFlagHeaders($eventObject) {
$response = $eventObject->getResponse();
if (Mage::helper('turpentine/esi')->shouldResponseUseEsi()) {
$response->setHeader('X-Turpentine-Esi',
Mage::registry('turpentine_esi_flag') ? '1' : '0');
Mage::helper('turpentine/debug')->logDebug(
'Set ESI flag header to: %s',
(Mage::registry('turpentine_esi_flag') ? '1' : '0') );
}
} | [
"public",
"function",
"setFlagHeaders",
"(",
"$",
"eventObject",
")",
"{",
"$",
"response",
"=",
"$",
"eventObject",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
"->",
"shouldResponseUseEsi",
"(",
")",
... | Check the ESI flag and set the ESI header if needed
Events: http_response_send_before
@param Varien_Object $eventObject
@return null | [
"Check",
"the",
"ESI",
"flag",
"and",
"set",
"the",
"ESI",
"header",
"if",
"needed"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L61-L70 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.checkCacheFlag | public function checkCacheFlag($eventObject) {
if (Mage::helper('turpentine/varnish')->shouldResponseUseVarnish()) {
$layoutXml = $eventObject->getLayout()->getUpdate()->asSimplexml();
foreach ($layoutXml->xpath('//turpentine_cache_flag') as $node) {
foreach ($node->attributes() as $attr => $value) {
if ($attr == 'value') {
if ( ! (string) $value) {
Mage::register('turpentine_nocache_flag', true, true);
return; //only need to set the flag once
}
}
}
}
}
} | php | public function checkCacheFlag($eventObject) {
if (Mage::helper('turpentine/varnish')->shouldResponseUseVarnish()) {
$layoutXml = $eventObject->getLayout()->getUpdate()->asSimplexml();
foreach ($layoutXml->xpath('//turpentine_cache_flag') as $node) {
foreach ($node->attributes() as $attr => $value) {
if ($attr == 'value') {
if ( ! (string) $value) {
Mage::register('turpentine_nocache_flag', true, true);
return; //only need to set the flag once
}
}
}
}
}
} | [
"public",
"function",
"checkCacheFlag",
"(",
"$",
"eventObject",
")",
"{",
"if",
"(",
"Mage",
"::",
"helper",
"(",
"'turpentine/varnish'",
")",
"->",
"shouldResponseUseVarnish",
"(",
")",
")",
"{",
"$",
"layoutXml",
"=",
"$",
"eventObject",
"->",
"getLayout",
... | Allows disabling page-caching by setting the cache flag on a controller
<customer_account>
<turpentine_cache_flag value="0" />
</customer_account>
Events: controller_action_layout_generate_blocks_after
@param Varien_Object $eventObject
@return null | [
"Allows",
"disabling",
"page",
"-",
"caching",
"by",
"setting",
"the",
"cache",
"flag",
"on",
"a",
"controller"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L84-L98 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.checkRedirectUrl | public function checkRedirectUrl($eventObject) {
$esiHelper = Mage::helper('turpentine/esi');
$url = $eventObject->getTransport()->getUrl();
$referer = Mage::helper('core/http')->getHttpReferer();
$dummyUrl = $esiHelper->getDummyUrl();
$reqUenc = Mage::helper('core')->urlDecode(
Mage::app()->getRequest()->getParam('uenc') );
if ($this->_checkIsEsiUrl($url)) {
if ($this->_checkIsNotEsiUrl($reqUenc) &&
Mage::getBaseUrl() == $url) {
$newUrl = $this->_fixupUencUrl($reqUenc);
} elseif ($this->_checkIsNotEsiUrl($referer)) {
$newUrl = $referer;
} else {
$newUrl = $dummyUrl;
}
// TODO: make sure this actually looks like a URL
$eventObject->getTransport()->setUrl($newUrl);
}
if ($eventObject->getTransport()->getUrl() != $url) {
Mage::helper('turpentine/debug')->logDebug(
'Detected redirect to ESI URL, changing: %s => %s',
$url, $eventObject->getTransport()->getUrl() );
}
} | php | public function checkRedirectUrl($eventObject) {
$esiHelper = Mage::helper('turpentine/esi');
$url = $eventObject->getTransport()->getUrl();
$referer = Mage::helper('core/http')->getHttpReferer();
$dummyUrl = $esiHelper->getDummyUrl();
$reqUenc = Mage::helper('core')->urlDecode(
Mage::app()->getRequest()->getParam('uenc') );
if ($this->_checkIsEsiUrl($url)) {
if ($this->_checkIsNotEsiUrl($reqUenc) &&
Mage::getBaseUrl() == $url) {
$newUrl = $this->_fixupUencUrl($reqUenc);
} elseif ($this->_checkIsNotEsiUrl($referer)) {
$newUrl = $referer;
} else {
$newUrl = $dummyUrl;
}
// TODO: make sure this actually looks like a URL
$eventObject->getTransport()->setUrl($newUrl);
}
if ($eventObject->getTransport()->getUrl() != $url) {
Mage::helper('turpentine/debug')->logDebug(
'Detected redirect to ESI URL, changing: %s => %s',
$url, $eventObject->getTransport()->getUrl() );
}
} | [
"public",
"function",
"checkRedirectUrl",
"(",
"$",
"eventObject",
")",
"{",
"$",
"esiHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
";",
"$",
"url",
"=",
"$",
"eventObject",
"->",
"getTransport",
"(",
")",
"->",
"getUrl",
"(",
")",
... | On controller redirects, check the target URL and set to home page
if it would otherwise go to a getBlock URL
@param Varien_Object $eventObject
@return null | [
"On",
"controller",
"redirects",
"check",
"the",
"target",
"URL",
"and",
"set",
"to",
"home",
"page",
"if",
"it",
"would",
"otherwise",
"go",
"to",
"a",
"getBlock",
"URL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L107-L133 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.loadCacheClearEvents | public function loadCacheClearEvents($eventObject) {
Varien_Profiler::start('turpentine::observer::esi::loadCacheClearEvents');
$events = Mage::helper('turpentine/esi')->getCacheClearEvents();
$appShim = Mage::getSingleton('turpentine/shim_mage_core_app');
foreach ($events as $ccEvent) {
$appShim->shim_addEventObserver('global', $ccEvent,
'turpentine_ban_'.$ccEvent, 'singleton',
'turpentine/observer_ban', 'banClientEsiCache');
}
Varien_Profiler::stop('turpentine::observer::esi::loadCacheClearEvents');
} | php | public function loadCacheClearEvents($eventObject) {
Varien_Profiler::start('turpentine::observer::esi::loadCacheClearEvents');
$events = Mage::helper('turpentine/esi')->getCacheClearEvents();
$appShim = Mage::getSingleton('turpentine/shim_mage_core_app');
foreach ($events as $ccEvent) {
$appShim->shim_addEventObserver('global', $ccEvent,
'turpentine_ban_'.$ccEvent, 'singleton',
'turpentine/observer_ban', 'banClientEsiCache');
}
Varien_Profiler::stop('turpentine::observer::esi::loadCacheClearEvents');
} | [
"public",
"function",
"loadCacheClearEvents",
"(",
"$",
"eventObject",
")",
"{",
"Varien_Profiler",
"::",
"start",
"(",
"'turpentine::observer::esi::loadCacheClearEvents'",
")",
";",
"$",
"events",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
"->",
"ge... | Load the cache clear events from stored config
@param Varien_Object $eventObject
@return null | [
"Load",
"the",
"cache",
"clear",
"events",
"from",
"stored",
"config"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L141-L151 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.setReplaceFormKeyFlag | public function setReplaceFormKeyFlag($eventObject) {
$esiHelper = Mage::helper('turpentine/esi');
$varnishHelper = Mage::helper('turpentine/varnish');
$request = Mage::app()->getRequest();
if ($esiHelper->shouldResponseUseEsi() &&
$varnishHelper->csrfFixupNeeded() &&
! $request->isPost()) {
Mage::register('replace_form_key', true);
}
} | php | public function setReplaceFormKeyFlag($eventObject) {
$esiHelper = Mage::helper('turpentine/esi');
$varnishHelper = Mage::helper('turpentine/varnish');
$request = Mage::app()->getRequest();
if ($esiHelper->shouldResponseUseEsi() &&
$varnishHelper->csrfFixupNeeded() &&
! $request->isPost()) {
Mage::register('replace_form_key', true);
}
} | [
"public",
"function",
"setReplaceFormKeyFlag",
"(",
"$",
"eventObject",
")",
"{",
"$",
"esiHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
";",
"$",
"varnishHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/varnish'",
")",
";",
"$",
... | Check the magento version and runtime env and set the replace_form_key
flag if needed
@param Varien_Object $eventObject
@return null | [
"Check",
"the",
"magento",
"version",
"and",
"runtime",
"env",
"and",
"set",
"the",
"replace_form_key",
"flag",
"if",
"needed"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L180-L189 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.replaceFormKeyPlaceholder | public function replaceFormKeyPlaceholder($eventObject) {
if (Mage::registry('replace_form_key')) {
$esiHelper = Mage::helper('turpentine/esi');
$response = $eventObject->getResponse();
$responseBody = $response->getBody();
$responseBody = str_replace('{{form_key_esi_placeholder}}',
$esiHelper->buildEsiIncludeFragment(
$esiHelper->getFormKeyEsiUrl() ),
$responseBody);
$response->setBody($responseBody);
}
} | php | public function replaceFormKeyPlaceholder($eventObject) {
if (Mage::registry('replace_form_key')) {
$esiHelper = Mage::helper('turpentine/esi');
$response = $eventObject->getResponse();
$responseBody = $response->getBody();
$responseBody = str_replace('{{form_key_esi_placeholder}}',
$esiHelper->buildEsiIncludeFragment(
$esiHelper->getFormKeyEsiUrl() ),
$responseBody);
$response->setBody($responseBody);
}
} | [
"public",
"function",
"replaceFormKeyPlaceholder",
"(",
"$",
"eventObject",
")",
"{",
"if",
"(",
"Mage",
"::",
"registry",
"(",
"'replace_form_key'",
")",
")",
"{",
"$",
"esiHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
";",
"$",
"respo... | Replace the form key placeholder with the ESI include fragment
@param Varien_Object $eventObject
@return null | [
"Replace",
"the",
"form",
"key",
"placeholder",
"with",
"the",
"ESI",
"include",
"fragment"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L197-L208 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi._getBlockLayoutHandles | protected function _getBlockLayoutHandles($block) {
Varien_Profiler::start('turpentine::observer::esi::_getBlockLayoutHandles');
$layout = $block->getLayout();
$layoutXml = Mage::helper('turpentine/esi')->getLayoutXml();
$activeHandles = array();
// get the xml node representing the block we're working on (from the
// default handle probably)
$blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode(
$layout, $block->getNameInLayout());
$childBlocks = Mage::helper('turpentine/data')
->getChildBlockNames($blockNode);
foreach ($childBlocks as $blockName) {
foreach ($layout->getUpdate()->getHandles() as $handle) {
// check if this handle has any block or reference tags that
// refer to this block or a child block, unless the handle name
// is blank
if ($handle !== '' && (strpos($handle, 'THEME') === 0 ||
$layoutXml->xpath(sprintf(
'//%s//*[@name=\'%s\']', $handle, $blockName )))) {
$activeHandles[] = $handle;
}
}
}
if ( ! $activeHandles) {
$activeHandles[] = 'default';
}
Varien_Profiler::stop('turpentine::observer::esi::_getBlockLayoutHandles');
return array_unique($activeHandles);
} | php | protected function _getBlockLayoutHandles($block) {
Varien_Profiler::start('turpentine::observer::esi::_getBlockLayoutHandles');
$layout = $block->getLayout();
$layoutXml = Mage::helper('turpentine/esi')->getLayoutXml();
$activeHandles = array();
// get the xml node representing the block we're working on (from the
// default handle probably)
$blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode(
$layout, $block->getNameInLayout());
$childBlocks = Mage::helper('turpentine/data')
->getChildBlockNames($blockNode);
foreach ($childBlocks as $blockName) {
foreach ($layout->getUpdate()->getHandles() as $handle) {
// check if this handle has any block or reference tags that
// refer to this block or a child block, unless the handle name
// is blank
if ($handle !== '' && (strpos($handle, 'THEME') === 0 ||
$layoutXml->xpath(sprintf(
'//%s//*[@name=\'%s\']', $handle, $blockName )))) {
$activeHandles[] = $handle;
}
}
}
if ( ! $activeHandles) {
$activeHandles[] = 'default';
}
Varien_Profiler::stop('turpentine::observer::esi::_getBlockLayoutHandles');
return array_unique($activeHandles);
} | [
"protected",
"function",
"_getBlockLayoutHandles",
"(",
"$",
"block",
")",
"{",
"Varien_Profiler",
"::",
"start",
"(",
"'turpentine::observer::esi::_getBlockLayoutHandles'",
")",
";",
"$",
"layout",
"=",
"$",
"block",
"->",
"getLayout",
"(",
")",
";",
"$",
"layout... | Get the active layout handles for this block and any child blocks
This is probably kind of slow since it uses a bunch of xpath searches
but this was the easiest way to get the info needed. Should be a target
for future optimization
There is an issue with encoding the used handles in the URL, if the used
handles change (ex customer logs in), the cached version of the page will
still have the old handles encoded in it's ESI url. This can lead to
weirdness like the "Log in" link displaying for already logged in
visitors on pages that were initially visited by not-logged-in visitors.
Not sure of a solution for this yet.
Above problem is currently solved by EsiController::_swapCustomerHandles()
but it would be best to find a more general solution to this.
@param Mage_Core_Block_Template $block
@return array | [
"Get",
"the",
"active",
"layout",
"handles",
"for",
"this",
"block",
"and",
"any",
"child",
"blocks"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L416-L444 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi._getDefaultEsiOptions | protected function _getDefaultEsiOptions($options) {
$esiHelper = Mage::helper('turpentine/esi');
$ttlParam = $esiHelper->getEsiTtlParam();
$methodParam = $esiHelper->getEsiMethodParam();
$cacheTypeParam = $esiHelper->getEsiCacheTypeParam();
$defaults = array(
$esiHelper->getEsiMethodParam() => 'esi',
$esiHelper->getEsiScopeParam() => 'global',
$esiHelper->getEsiCacheTypeParam() => 'public',
'dummy_blocks' => array(),
'registry_keys' => array(),
);
$options = array_merge($defaults, $options);
// set the default TTL
if ( ! isset($options[$ttlParam])) {
if ($options[$cacheTypeParam] == 'private' || $options[$cacheTypeParam] == 'customer_group') {
switch ($options[$methodParam]) {
case 'ajax':
$options[$ttlParam] = '0';
break;
case 'esi':
default:
$options[$ttlParam] = $esiHelper->getDefaultEsiTtl();
break;
}
} else {
$options[$ttlParam] = Mage::helper('turpentine/varnish')
->getDefaultTtl();
}
}
return $options;
} | php | protected function _getDefaultEsiOptions($options) {
$esiHelper = Mage::helper('turpentine/esi');
$ttlParam = $esiHelper->getEsiTtlParam();
$methodParam = $esiHelper->getEsiMethodParam();
$cacheTypeParam = $esiHelper->getEsiCacheTypeParam();
$defaults = array(
$esiHelper->getEsiMethodParam() => 'esi',
$esiHelper->getEsiScopeParam() => 'global',
$esiHelper->getEsiCacheTypeParam() => 'public',
'dummy_blocks' => array(),
'registry_keys' => array(),
);
$options = array_merge($defaults, $options);
// set the default TTL
if ( ! isset($options[$ttlParam])) {
if ($options[$cacheTypeParam] == 'private' || $options[$cacheTypeParam] == 'customer_group') {
switch ($options[$methodParam]) {
case 'ajax':
$options[$ttlParam] = '0';
break;
case 'esi':
default:
$options[$ttlParam] = $esiHelper->getDefaultEsiTtl();
break;
}
} else {
$options[$ttlParam] = Mage::helper('turpentine/varnish')
->getDefaultTtl();
}
}
return $options;
} | [
"protected",
"function",
"_getDefaultEsiOptions",
"(",
"$",
"options",
")",
"{",
"$",
"esiHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
";",
"$",
"ttlParam",
"=",
"$",
"esiHelper",
"->",
"getEsiTtlParam",
"(",
")",
";",
"$",
"methodPara... | Get the default ESI options
@return array | [
"Get",
"the",
"default",
"ESI",
"options"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L451-L485 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi._getComplexRegistryData | protected function _getComplexRegistryData($valueOptions, $value) {
$idMethod = @$valueOptions['id_method'] ?
$valueOptions['id_method'] : 'getId';
$model = @$valueOptions['model'] ?
$valueOptions['model'] : Mage::helper('turpentine/data')
->getModelName($value);
$data = array(
'model' => $model,
'id' => $value->{$idMethod}(),
);
return $data;
} | php | protected function _getComplexRegistryData($valueOptions, $value) {
$idMethod = @$valueOptions['id_method'] ?
$valueOptions['id_method'] : 'getId';
$model = @$valueOptions['model'] ?
$valueOptions['model'] : Mage::helper('turpentine/data')
->getModelName($value);
$data = array(
'model' => $model,
'id' => $value->{$idMethod}(),
);
return $data;
} | [
"protected",
"function",
"_getComplexRegistryData",
"(",
"$",
"valueOptions",
",",
"$",
"value",
")",
"{",
"$",
"idMethod",
"=",
"@",
"$",
"valueOptions",
"[",
"'id_method'",
"]",
"?",
"$",
"valueOptions",
"[",
"'id_method'",
"]",
":",
"'getId'",
";",
"$",
... | Get the complex registry entry data
@param array $valueOptions
@param mixed $value
@return array | [
"Get",
"the",
"complex",
"registry",
"entry",
"data"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L494-L505 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi._fixupUencUrl | protected function _fixupUencUrl($uencUrl) {
$esiHelper = Mage::helper('turpentine/esi');
$corsOrigin = $esiHelper->getCorsOrigin();
if ($corsOrigin != $esiHelper->getCorsOrigin($uencUrl)) {
return $corsOrigin.parse_url($uencUrl, PHP_URL_PATH);
} else {
return $uencUrl;
}
} | php | protected function _fixupUencUrl($uencUrl) {
$esiHelper = Mage::helper('turpentine/esi');
$corsOrigin = $esiHelper->getCorsOrigin();
if ($corsOrigin != $esiHelper->getCorsOrigin($uencUrl)) {
return $corsOrigin.parse_url($uencUrl, PHP_URL_PATH);
} else {
return $uencUrl;
}
} | [
"protected",
"function",
"_fixupUencUrl",
"(",
"$",
"uencUrl",
")",
"{",
"$",
"esiHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'turpentine/esi'",
")",
";",
"$",
"corsOrigin",
"=",
"$",
"esiHelper",
"->",
"getCorsOrigin",
"(",
")",
";",
"if",
"(",
"$",
"co... | Fix a URL to ensure it uses Magento's base URL instead of the backend
URL
@param string $uencUrl
@return string | [
"Fix",
"a",
"URL",
"to",
"ensure",
"it",
"uses",
"Magento",
"s",
"base",
"URL",
"instead",
"of",
"the",
"backend",
"URL"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L514-L522 | train |
nexcess/magento-turpentine | app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php | Nexcessnet_Turpentine_Model_Observer_Esi.hookToAddToWishlistBefore | public function hookToAddToWishlistBefore($observer)
{
$key = Mage::getSingleton('core/session')->getFormKey();
$observer->getEvent()->getRequest()->setParam('form_key', $key);
return $this;
} | php | public function hookToAddToWishlistBefore($observer)
{
$key = Mage::getSingleton('core/session')->getFormKey();
$observer->getEvent()->getRequest()->setParam('form_key', $key);
return $this;
} | [
"public",
"function",
"hookToAddToWishlistBefore",
"(",
"$",
"observer",
")",
"{",
"$",
"key",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'core/session'",
")",
"->",
"getFormKey",
"(",
")",
";",
"$",
"observer",
"->",
"getEvent",
"(",
")",
"->",
"getRequest",
... | Set the form key on the add to wishlist request
@param $observer
@return Nexcessnet_Turpentine_Model_Observer_Esi | [
"Set",
"the",
"form",
"key",
"on",
"the",
"add",
"to",
"wishlist",
"request"
] | c670a492a18cf495d87699e0dbd712ad03fd84ad | https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php#L579-L584 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.