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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Opifer/Cms | src/MediaBundle/Controller/Backend/MediaController.php | MediaController.deleteAction | public function deleteAction(Request $request, $id)
{
$mediaManager = $this->get('opifer.media.media_manager');
$media = $mediaManager->getRepository()->find($id);
$dispatcher = $this->get('event_dispatcher');
$event = new MediaResponseEvent($media, $request);
$dispatcher->dispatch(OpiferMediaEvents::MEDIA_CONTROLLER_DELETE, $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
$mediaManager->remove($media);
return $this->redirectToRoute('opifer_media_media_index');
} | php | public function deleteAction(Request $request, $id)
{
$mediaManager = $this->get('opifer.media.media_manager');
$media = $mediaManager->getRepository()->find($id);
$dispatcher = $this->get('event_dispatcher');
$event = new MediaResponseEvent($media, $request);
$dispatcher->dispatch(OpiferMediaEvents::MEDIA_CONTROLLER_DELETE, $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
$mediaManager->remove($media);
return $this->redirectToRoute('opifer_media_media_index');
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"mediaManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.media.media_manager'",
")",
";",
"$",
"media",
"=",
"$",
"mediaManager",
"->",
"getRepository",
... | Deletes a media item.
@param Request $request
@param int $id
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Deletes",
"a",
"media",
"item",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Controller/Backend/MediaController.php#L179-L195 | train |
Opifer/Cms | src/EavBundle/Model/ValueSet.php | ValueSet.getSortedValues | public function getSortedValues($order = 'asc')
{
$values = $this->values->toArray();
usort($values, function ($a, $b) use ($order) {
$left = $a->getAttribute()->getSort();
$right = $b->getAttribute()->getSort();
if ($order == 'desc') {
return ($left < $right) ? 1 : -1;
}
return ($left > $right) ? 1 : -1;
});
return $values;
} | php | public function getSortedValues($order = 'asc')
{
$values = $this->values->toArray();
usort($values, function ($a, $b) use ($order) {
$left = $a->getAttribute()->getSort();
$right = $b->getAttribute()->getSort();
if ($order == 'desc') {
return ($left < $right) ? 1 : -1;
}
return ($left > $right) ? 1 : -1;
});
return $values;
} | [
"public",
"function",
"getSortedValues",
"(",
"$",
"order",
"=",
"'asc'",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
"->",
"toArray",
"(",
")",
";",
"usort",
"(",
"$",
"values",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
... | Get Sorted Values
This method wraps all values in an array, sorted by the attribute's sort
property.
We use this to render a whole set of form types, which should be displayed
in some order. When you want to be able to get a form field by it's name
and place it on a custom place, use the getNamedValues() method.
@param string $order
@return array | [
"Get",
"Sorted",
"Values"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/ValueSet.php#L167-L182 | train |
Opifer/Cms | src/EavBundle/Model/ValueSet.php | ValueSet.getNamedValues | public function getNamedValues($order = 'asc')
{
$values = $this->getSortedValues($order);
$valueArray = [];
foreach ($values as $value) {
$valueArray[$value->getAttribute()->getName()] = $value;
}
return $valueArray;
} | php | public function getNamedValues($order = 'asc')
{
$values = $this->getSortedValues($order);
$valueArray = [];
foreach ($values as $value) {
$valueArray[$value->getAttribute()->getName()] = $value;
}
return $valueArray;
} | [
"public",
"function",
"getNamedValues",
"(",
"$",
"order",
"=",
"'asc'",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getSortedValues",
"(",
"$",
"order",
")",
";",
"$",
"valueArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",... | Get Named Values
When the automatic sort of form ValueSet form fields does not matter,
you can use this method to get a associative array where the keys hold
the attribute name.
To render a specific form field in Twig you could do something like this:
{{ form_row(form.valueset.namedvalues.yourformfield) }}
@return array | [
"Get",
"Named",
"Values"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/ValueSet.php#L197-L207 | train |
Opifer/Cms | src/EavBundle/Model/ValueSet.php | ValueSet.has | public function has($value)
{
if (!is_string($value) && !is_array($value)) {
throw new \InvalidArgumentException('The ValueSet\'s "has" method requires the argument to be of type string or array');
}
if (is_string($value)) {
return $this->__isset($value);
} elseif (is_array($value)) {
foreach ($value as $name) {
if (!$this->__isset($value)) {
return false;
}
}
return true;
}
} | php | public function has($value)
{
if (!is_string($value) && !is_array($value)) {
throw new \InvalidArgumentException('The ValueSet\'s "has" method requires the argument to be of type string or array');
}
if (is_string($value)) {
return $this->__isset($value);
} elseif (is_array($value)) {
foreach ($value as $name) {
if (!$this->__isset($value)) {
return false;
}
}
return true;
}
} | [
"public",
"function",
"has",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The ValueSet\\'s \"has\" method... | Checks if a certain value exists on the valueset
Created for cleaner syntax in Twig:
{{ content.valueset.has('attributename') }}
or
{{ content.valueset.has(['attributename', 'anotherattributename']) }}
@param string|array $value
@return boolean | [
"Checks",
"if",
"a",
"certain",
"value",
"exists",
"on",
"the",
"valueset"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/ValueSet.php#L222-L239 | train |
Opifer/Cms | src/EavBundle/Model/ValueSet.php | ValueSet.getValueByAttributeId | public function getValueByAttributeId($attributeId)
{
foreach ($this->values as $valueObject) {
if ($valueObject->getAttribute()->getId() == $attributeId) {
return $valueObject;
}
}
return null;
} | php | public function getValueByAttributeId($attributeId)
{
foreach ($this->values as $valueObject) {
if ($valueObject->getAttribute()->getId() == $attributeId) {
return $valueObject;
}
}
return null;
} | [
"public",
"function",
"getValueByAttributeId",
"(",
"$",
"attributeId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"valueObject",
")",
"{",
"if",
"(",
"$",
"valueObject",
"->",
"getAttribute",
"(",
")",
"->",
"getId",
"(",
")",
"==... | Get a value by it's attribute ID
@param int $attributeId
@return ValueInterface|null | [
"Get",
"a",
"value",
"by",
"it",
"s",
"attribute",
"ID"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/ValueSet.php#L276-L285 | train |
Opifer/Cms | src/ContentBundle/Controller/Backend/ContentEditorController.php | ContentEditorController.tocAction | public function tocAction($owner, $ownerId)
{
/** @var BlockProviderInterface $provider */
$provider = $this->get('opifer.content.block_provider_pool')->getProvider($owner);
$object = $provider->getBlockOwner($ownerId);
/** @var Environment $environment */
$environment = $this->get('opifer.content.block_environment');
$environment->setDraft(true)->setObject($object);
$environment->setBlockMode('manage');
$twigAnalyzer = $this->get('opifer.content.twig_analyzer');
$parameters = [
'environment' => $environment,
'analyzer' => $twigAnalyzer,
'object' => $environment->getObject(),
];
return $this->render('OpiferContentBundle:Content:toc.html.twig', $parameters);
} | php | public function tocAction($owner, $ownerId)
{
/** @var BlockProviderInterface $provider */
$provider = $this->get('opifer.content.block_provider_pool')->getProvider($owner);
$object = $provider->getBlockOwner($ownerId);
/** @var Environment $environment */
$environment = $this->get('opifer.content.block_environment');
$environment->setDraft(true)->setObject($object);
$environment->setBlockMode('manage');
$twigAnalyzer = $this->get('opifer.content.twig_analyzer');
$parameters = [
'environment' => $environment,
'analyzer' => $twigAnalyzer,
'object' => $environment->getObject(),
];
return $this->render('OpiferContentBundle:Content:toc.html.twig', $parameters);
} | [
"public",
"function",
"tocAction",
"(",
"$",
"owner",
",",
"$",
"ownerId",
")",
"{",
"/** @var BlockProviderInterface $provider */",
"$",
"provider",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.block_provider_pool'",
")",
"->",
"getProvider",
"(",
"$",
"o... | Table of Contents tree
@param string $owner
@param integer $ownerId
@return Response | [
"Table",
"of",
"Contents",
"tree"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/ContentEditorController.php#L67-L87 | train |
Opifer/Cms | src/CmsBundle/Repository/CronRepository.php | CronRepository.findDue | public function findDue()
{
/** @var Cron[] $active */
$active = $this->createQueryBuilder('c')
->where('c.state <> :canceled')
->andWhere('c.state <> :running OR (c.state = :running AND c.startedAt < :hourAgo)')
->orderBy('c.priority', 'DESC')
->setParameters([
'canceled' => Cron::STATE_CANCELED,
'running' => Cron::STATE_RUNNING,
'hourAgo' => new \DateTime('-67 minutes'),
])
->getQuery()
->getResult()
;
$due = [];
foreach ($active as $cron) {
if ($cron->isDue()) {
$due[] = $cron;
}
}
return new ArrayCollection($due);
} | php | public function findDue()
{
/** @var Cron[] $active */
$active = $this->createQueryBuilder('c')
->where('c.state <> :canceled')
->andWhere('c.state <> :running OR (c.state = :running AND c.startedAt < :hourAgo)')
->orderBy('c.priority', 'DESC')
->setParameters([
'canceled' => Cron::STATE_CANCELED,
'running' => Cron::STATE_RUNNING,
'hourAgo' => new \DateTime('-67 minutes'),
])
->getQuery()
->getResult()
;
$due = [];
foreach ($active as $cron) {
if ($cron->isDue()) {
$due[] = $cron;
}
}
return new ArrayCollection($due);
} | [
"public",
"function",
"findDue",
"(",
")",
"{",
"/** @var Cron[] $active */",
"$",
"active",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"where",
"(",
"'c.state <> :canceled'",
")",
"->",
"andWhere",
"(",
"'c.state <> :running OR (c.state = ... | Find all cronjobs which are due.
@return \Doctrine\Common\Collections\ArrayCollection | [
"Find",
"all",
"cronjobs",
"which",
"are",
"due",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Repository/CronRepository.php#L22-L46 | train |
Opifer/Cms | src/FormBundle/Controller/Api/FormController.php | FormController.getFormAction | public function getFormAction($id)
{
/** @var Form $form */
$form = $this->get('opifer.form.form_manager')->getRepository()->find($id);
if (!$form) {
throw $this->createNotFoundException('The form could not be found');
}
/** @var Post $post */
$post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
$postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);
$definition = $this->get('liform')->transform($postForm);
/** @var CsrfTokenManagerInterface $csrf */
$csrf = $this->get('security.csrf.token_manager');
$token = $csrf->refreshToken($form->getName());
// We're stuck with a legacy form structure here, which we'd like to hide on the API.
$fields = $definition['properties']['valueset']['properties']['namedvalues']['properties'];
$fields['_token'] = [
'widget' => 'hidden',
'value' => $token->getValue()
];
return new JsonResponse($fields);
} | php | public function getFormAction($id)
{
/** @var Form $form */
$form = $this->get('opifer.form.form_manager')->getRepository()->find($id);
if (!$form) {
throw $this->createNotFoundException('The form could not be found');
}
/** @var Post $post */
$post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
$postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);
$definition = $this->get('liform')->transform($postForm);
/** @var CsrfTokenManagerInterface $csrf */
$csrf = $this->get('security.csrf.token_manager');
$token = $csrf->refreshToken($form->getName());
// We're stuck with a legacy form structure here, which we'd like to hide on the API.
$fields = $definition['properties']['valueset']['properties']['namedvalues']['properties'];
$fields['_token'] = [
'widget' => 'hidden',
'value' => $token->getValue()
];
return new JsonResponse($fields);
} | [
"public",
"function",
"getFormAction",
"(",
"$",
"id",
")",
"{",
"/** @var Form $form */",
"$",
"form",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.form_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
... | Get a definition of the given form
@param $id
@return JsonResponse | [
"Get",
"a",
"definition",
"of",
"the",
"given",
"form"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/Api/FormController.php#L23-L50 | train |
Opifer/Cms | src/FormBundle/Controller/Api/FormController.php | FormController.postFormPostAction | public function postFormPostAction(Request $request, $id)
{
/** @var Form $form */
$form = $this->get('opifer.form.form_manager')->getRepository()->find($id);
if (!$form) {
throw $this->createNotFoundException('The form could not be found');
}
$data = json_decode($request->getContent(), true);
$token = $data['_token'];
if ($this->isCsrfTokenValid($form->getName(), $token)) {
throw new InvalidCsrfTokenException();
}
// Remove the token from the data array, since it's not part of the form.
unset($data['_token']);
// We're stuck with a legacy form structure here, which we'd like to hide on the API.
$data = ['valueset' => ['namedvalues' => $data]];
/** @var Post $post */
$post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
$post->setForm($form);
$postForm = $this->createForm(PostType::class, $post, ['form_id' => $id, 'csrf_protection' => false]);
$postForm->submit($data);
if ($postForm->isSubmitted() && $postForm->isValid()) {
$this->get('opifer.form.post_manager')->save($post);
return new JsonResponse(['message' => 'Success'], 201);
}
return new JsonResponse([
'errors' => (string) $postForm->getErrors()
], 400);
} | php | public function postFormPostAction(Request $request, $id)
{
/** @var Form $form */
$form = $this->get('opifer.form.form_manager')->getRepository()->find($id);
if (!$form) {
throw $this->createNotFoundException('The form could not be found');
}
$data = json_decode($request->getContent(), true);
$token = $data['_token'];
if ($this->isCsrfTokenValid($form->getName(), $token)) {
throw new InvalidCsrfTokenException();
}
// Remove the token from the data array, since it's not part of the form.
unset($data['_token']);
// We're stuck with a legacy form structure here, which we'd like to hide on the API.
$data = ['valueset' => ['namedvalues' => $data]];
/** @var Post $post */
$post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
$post->setForm($form);
$postForm = $this->createForm(PostType::class, $post, ['form_id' => $id, 'csrf_protection' => false]);
$postForm->submit($data);
if ($postForm->isSubmitted() && $postForm->isValid()) {
$this->get('opifer.form.post_manager')->save($post);
return new JsonResponse(['message' => 'Success'], 201);
}
return new JsonResponse([
'errors' => (string) $postForm->getErrors()
], 400);
} | [
"public",
"function",
"postFormPostAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"/** @var Form $form */",
"$",
"form",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.form_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"find",
... | Handle the creation of a form post
@param Request $request
@param $id
@return JsonResponse | [
"Handle",
"the",
"creation",
"of",
"a",
"form",
"post"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/Api/FormController.php#L60-L97 | train |
aegis-security/JWT | src/Builder.php | Builder.setRegisteredClaim | protected function setRegisteredClaim($name, $value, $replicate)
{
$this->set($name, $value);
if ($replicate) {
$this->headers[$name] = $this->claims[$name];
}
return $this;
} | php | protected function setRegisteredClaim($name, $value, $replicate)
{
$this->set($name, $value);
if ($replicate) {
$this->headers[$name] = $this->claims[$name];
}
return $this;
} | [
"protected",
"function",
"setRegisteredClaim",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"replicate",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"replicate",
")",
"{",
"$",
"this",
"->",
... | Configures a registed claim
@param string $name
@param mixed $value
@param boolean $replicate
@return Builder | [
"Configures",
"a",
"registed",
"claim"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Builder.php#L169-L178 | train |
aegis-security/JWT | src/Builder.php | Builder.setHeader | public function setHeader($name, $value)
{
if ($this->signature) {
throw new \BadMethodCallException('You must unsign before make changes');
}
$this->headers[(string) $name] = $this->claimFactory->create($name, $value);
return $this;
} | php | public function setHeader($name, $value)
{
if ($this->signature) {
throw new \BadMethodCallException('You must unsign before make changes');
}
$this->headers[(string) $name] = $this->claimFactory->create($name, $value);
return $this;
} | [
"public",
"function",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"signature",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'You must unsign before make changes'",
")",
";",
"}",
"$",
"this",
... | Configures a header item
@param string $name
@param mixed $value
@return Builder
@throws \BadMethodCallException When data has been already signed | [
"Configures",
"a",
"header",
"item"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Builder.php#L190-L199 | train |
aegis-security/JWT | src/Builder.php | Builder.set | public function set($name, $value)
{
if ($this->signature) {
throw new \BadMethodCallException('You must unsign before make changes');
}
$this->claims[(string) $name] = $this->claimFactory->create($name, $value);
return $this;
} | php | public function set($name, $value)
{
if ($this->signature) {
throw new \BadMethodCallException('You must unsign before make changes');
}
$this->claims[(string) $name] = $this->claimFactory->create($name, $value);
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"signature",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'You must unsign before make changes'",
")",
";",
"}",
"$",
"this",
"->",... | Configures a claim item
@param string $name
@param mixed $value
@return Builder
@throws \BadMethodCallException When data has been already signed | [
"Configures",
"a",
"claim",
"item"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Builder.php#L211-L220 | train |
aegis-security/JWT | src/Builder.php | Builder.sign | public function sign(Signer $signer, $key)
{
$signer->modifyHeader($this->headers);
$this->signature = $signer->sign(
$this->getToken()->getPayload(),
$key
);
return $this;
} | php | public function sign(Signer $signer, $key)
{
$signer->modifyHeader($this->headers);
$this->signature = $signer->sign(
$this->getToken()->getPayload(),
$key
);
return $this;
} | [
"public",
"function",
"sign",
"(",
"Signer",
"$",
"signer",
",",
"$",
"key",
")",
"{",
"$",
"signer",
"->",
"modifyHeader",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"this",
"->",
"signature",
"=",
"$",
"signer",
"->",
"sign",
"(",
"$",
"th... | Signs the data
@param Signer $signer
@param string $key
@return Builder | [
"Signs",
"the",
"data"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Builder.php#L230-L240 | train |
aegis-security/JWT | src/Builder.php | Builder.getToken | public function getToken()
{
$payload = array(
$this->serializer->toBase64URL($this->serializer->toJSON($this->headers)),
$this->serializer->toBase64URL($this->serializer->toJSON($this->claims))
);
if ($this->signature !== null) {
$payload[] = $this->serializer->toBase64URL($this->signature);
}
return new Token($this->headers, $this->claims, $this->signature, $payload);
} | php | public function getToken()
{
$payload = array(
$this->serializer->toBase64URL($this->serializer->toJSON($this->headers)),
$this->serializer->toBase64URL($this->serializer->toJSON($this->claims))
);
if ($this->signature !== null) {
$payload[] = $this->serializer->toBase64URL($this->signature);
}
return new Token($this->headers, $this->claims, $this->signature, $payload);
} | [
"public",
"function",
"getToken",
"(",
")",
"{",
"$",
"payload",
"=",
"array",
"(",
"$",
"this",
"->",
"serializer",
"->",
"toBase64URL",
"(",
"$",
"this",
"->",
"serializer",
"->",
"toJSON",
"(",
"$",
"this",
"->",
"headers",
")",
")",
",",
"$",
"th... | Returns the resultant token
@return Token | [
"Returns",
"the",
"resultant",
"token"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Builder.php#L259-L271 | train |
Opifer/Cms | src/EavBundle/Manager/EavManager.php | EavManager.initializeEntity | public function initializeEntity(SchemaInterface $schema)
{
$valueSet = $this->createValueSet();
$valueSet->setSchema($schema);
// To avoid persisting Value entities with no actual value to the database
// we create empty ones, that will be removed on postPersist events.
$this->replaceEmptyValues($valueSet);
$entity = $schema->getObjectClass();
$entity = new $entity();
if (!$entity instanceof EntityInterface) {
throw new \Exception(sprintf('The entity specified in schema "%d" schema must implement Opifer\EavBundle\Model\EntityInterface.', $schema->getId()));
}
$entity->setValueSet($valueSet);
$entity->setSchema($schema);
return $entity;
} | php | public function initializeEntity(SchemaInterface $schema)
{
$valueSet = $this->createValueSet();
$valueSet->setSchema($schema);
// To avoid persisting Value entities with no actual value to the database
// we create empty ones, that will be removed on postPersist events.
$this->replaceEmptyValues($valueSet);
$entity = $schema->getObjectClass();
$entity = new $entity();
if (!$entity instanceof EntityInterface) {
throw new \Exception(sprintf('The entity specified in schema "%d" schema must implement Opifer\EavBundle\Model\EntityInterface.', $schema->getId()));
}
$entity->setValueSet($valueSet);
$entity->setSchema($schema);
return $entity;
} | [
"public",
"function",
"initializeEntity",
"(",
"SchemaInterface",
"$",
"schema",
")",
"{",
"$",
"valueSet",
"=",
"$",
"this",
"->",
"createValueSet",
"(",
")",
";",
"$",
"valueSet",
"->",
"setSchema",
"(",
"$",
"schema",
")",
";",
"// To avoid persisting Value... | Initializes an entity from a schema to work properly with this bundle.
@param SchemaInterface $schema
@throws \Exception If the entity is not an instance of EntityInterface
@return EntityInterface | [
"Initializes",
"an",
"entity",
"from",
"a",
"schema",
"to",
"work",
"properly",
"with",
"this",
"bundle",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Manager/EavManager.php#L39-L59 | train |
Opifer/Cms | src/EavBundle/Manager/EavManager.php | EavManager.replaceEmptyValues | public function replaceEmptyValues(ValueSetInterface $valueSet)
{
// collect persisted attributevalues
$persistedAttributes = array();
foreach ($valueSet->getValues() as $value) {
$persistedAttributes[] = $value->getAttribute();
}
$newValues = array();
// Create empty entities for missing attributes
$missingAttributes = array_diff($valueSet->getAttributes()->toArray(), $persistedAttributes);
foreach ($missingAttributes as $attribute) {
$provider = $this->providerPool->getValue($attribute->getValueType());
$valueClass = $provider->getEntity();
$value = new $valueClass();
$valueSet->addValue($value);
$value->setValueSet($valueSet);
$value->setAttribute($attribute);
$newValues[] = $value;
}
return $newValues;
} | php | public function replaceEmptyValues(ValueSetInterface $valueSet)
{
// collect persisted attributevalues
$persistedAttributes = array();
foreach ($valueSet->getValues() as $value) {
$persistedAttributes[] = $value->getAttribute();
}
$newValues = array();
// Create empty entities for missing attributes
$missingAttributes = array_diff($valueSet->getAttributes()->toArray(), $persistedAttributes);
foreach ($missingAttributes as $attribute) {
$provider = $this->providerPool->getValue($attribute->getValueType());
$valueClass = $provider->getEntity();
$value = new $valueClass();
$valueSet->addValue($value);
$value->setValueSet($valueSet);
$value->setAttribute($attribute);
$newValues[] = $value;
}
return $newValues;
} | [
"public",
"function",
"replaceEmptyValues",
"(",
"ValueSetInterface",
"$",
"valueSet",
")",
"{",
"// collect persisted attributevalues",
"$",
"persistedAttributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"valueSet",
"->",
"getValues",
"(",
")",
"as",
"$... | Creates empty entities for non-persisted attributes.
@param ValueSetInterface $valueSet
@return array | [
"Creates",
"empty",
"entities",
"for",
"non",
"-",
"persisted",
"attributes",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Manager/EavManager.php#L68-L93 | train |
aegis-security/JWT | src/Signer/Hmac.php | Hmac.hashEquals | public function hashEquals($expected, $generated)
{
$expectedLength = strlen($expected);
if ($expectedLength !== strlen($generated)) {
return false;
}
$res = 0;
for ($i = 0; $i < $expectedLength; ++$i) {
$res |= ord($expected[$i]) ^ ord($generated[$i]);
}
return $res === 0;
} | php | public function hashEquals($expected, $generated)
{
$expectedLength = strlen($expected);
if ($expectedLength !== strlen($generated)) {
return false;
}
$res = 0;
for ($i = 0; $i < $expectedLength; ++$i) {
$res |= ord($expected[$i]) ^ ord($generated[$i]);
}
return $res === 0;
} | [
"public",
"function",
"hashEquals",
"(",
"$",
"expected",
",",
"$",
"generated",
")",
"{",
"$",
"expectedLength",
"=",
"strlen",
"(",
"$",
"expected",
")",
";",
"if",
"(",
"$",
"expectedLength",
"!==",
"strlen",
"(",
"$",
"generated",
")",
")",
"{",
"r... | PHP < 5.6 timing attack safe hash comparison
@param string $expected
@param string $generated
@return boolean | [
"PHP",
"<",
"5",
".",
"6",
"timing",
"attack",
"safe",
"hash",
"comparison"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signer/Hmac.php#L45-L60 | train |
CI-Craftsman/CLI | src/Core/Generator.php | Generator.make | protected function make($filenames, $template = 'base.php.twig', array $options = array())
{
foreach ((array) $filenames as $filename)
{
if (! $this->getOption('force') && $this->fs->exists($filename))
{
throw new \RuntimeException(sprintf('Cannot duplicate %s', $filename));
}
$reflection = new \ReflectionClass(get_class($this));
if ($reflection->getShortName() === 'Migration')
{
$this->twig->addFunction(new \Twig_SimpleFunction('argument',
function ($field = "") {
return array_combine(array('name','type'), explode(':', $field));
}
));
foreach ($this->getArgument('options') as $option)
{
list($key, $value) = explode(':', $option);
$options[$key] = $value;
}
}
$output = $this->twig->loadTemplate($template)->render($options);
$this->fs->dumpFile($filename, $output);
}
return true;
} | php | protected function make($filenames, $template = 'base.php.twig', array $options = array())
{
foreach ((array) $filenames as $filename)
{
if (! $this->getOption('force') && $this->fs->exists($filename))
{
throw new \RuntimeException(sprintf('Cannot duplicate %s', $filename));
}
$reflection = new \ReflectionClass(get_class($this));
if ($reflection->getShortName() === 'Migration')
{
$this->twig->addFunction(new \Twig_SimpleFunction('argument',
function ($field = "") {
return array_combine(array('name','type'), explode(':', $field));
}
));
foreach ($this->getArgument('options') as $option)
{
list($key, $value) = explode(':', $option);
$options[$key] = $value;
}
}
$output = $this->twig->loadTemplate($template)->render($options);
$this->fs->dumpFile($filename, $output);
}
return true;
} | [
"protected",
"function",
"make",
"(",
"$",
"filenames",
",",
"$",
"template",
"=",
"'base.php.twig'",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"filenames",
"as",
"$",
"filename",
")",
"{",
... | Generate files based on templates.
@param mixed $filenames The file to be written to
@param mixed $paths The Twig_Loader_Filesystem template path
@param array $options The data to write into the file
@param string $template The template file
@return bool Returns true if the file has been created | [
"Generate",
"files",
"based",
"on",
"templates",
"."
] | 74b900f931548ec5a81ad8c2158d215594f4d601 | https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Core/Generator.php#L81-L112 | train |
CI-Craftsman/CLI | src/Core/Generator.php | Generator.createDirectory | public function createDirectory($dirPath)
{
if (! $this->fs->exists($dirPath))
{
$this->fs->mkdir($dirPath);
}
} | php | public function createDirectory($dirPath)
{
if (! $this->fs->exists($dirPath))
{
$this->fs->mkdir($dirPath);
}
} | [
"public",
"function",
"createDirectory",
"(",
"$",
"dirPath",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fs",
"->",
"exists",
"(",
"$",
"dirPath",
")",
")",
"{",
"$",
"this",
"->",
"fs",
"->",
"mkdir",
"(",
"$",
"dirPath",
")",
";",
"}",
"}"
] | Create a directory if doesn't exists.
@param string $dirPath Directory path
@return null | [
"Create",
"a",
"directory",
"if",
"doesn",
"t",
"exists",
"."
] | 74b900f931548ec5a81ad8c2158d215594f4d601 | https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Core/Generator.php#L120-L126 | train |
Opifer/Cms | src/MediaBundle/EventListener/MediaListener.php | MediaListener.getProvider | public function getProvider(LifecycleEventArgs $args)
{
$provider = $args->getObject()->getProvider();
if (!$provider) {
throw new \Exception('Please set a provider on the entity before persisting any media');
}
return $this->container->get('opifer.media.provider.pool')->getProvider($provider);
} | php | public function getProvider(LifecycleEventArgs $args)
{
$provider = $args->getObject()->getProvider();
if (!$provider) {
throw new \Exception('Please set a provider on the entity before persisting any media');
}
return $this->container->get('opifer.media.provider.pool')->getProvider($provider);
} | [
"public",
"function",
"getProvider",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
"{",
"$",
"provider",
"=",
"$",
"args",
"->",
"getObject",
"(",
")",
"->",
"getProvider",
"(",
")",
";",
"if",
"(",
"!",
"$",
"provider",
")",
"{",
"throw",
"new",
"\\",
... | Get the provider pool.
@return \Opifer\MediaBundle\Provider\ProviderInterface | [
"Get",
"the",
"provider",
"pool",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/EventListener/MediaListener.php#L62-L71 | train |
Opifer/Cms | src/MediaBundle/Provider/VimeoProvider.php | VimeoProvider.saveThumbnail | public function saveThumbnail(MediaInterface $media, $url)
{
$thumb = $this->mediaManager->createMedia();
$thumb
->setStatus(Media::STATUS_HASPARENT)
->setName($media->getName().'_thumb')
->setProvider('image')
;
$filename = '/tmp/'.basename($url);
$filesystem = new Filesystem();
$filesystem->dumpFile($filename, file_get_contents($url));
$thumb->temp = $filename;
$thumb->setFile(new UploadedFile($filename, basename($url)));
$this->mediaManager->save($thumb);
return $thumb;
} | php | public function saveThumbnail(MediaInterface $media, $url)
{
$thumb = $this->mediaManager->createMedia();
$thumb
->setStatus(Media::STATUS_HASPARENT)
->setName($media->getName().'_thumb')
->setProvider('image')
;
$filename = '/tmp/'.basename($url);
$filesystem = new Filesystem();
$filesystem->dumpFile($filename, file_get_contents($url));
$thumb->temp = $filename;
$thumb->setFile(new UploadedFile($filename, basename($url)));
$this->mediaManager->save($thumb);
return $thumb;
} | [
"public",
"function",
"saveThumbnail",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"url",
")",
"{",
"$",
"thumb",
"=",
"$",
"this",
"->",
"mediaManager",
"->",
"createMedia",
"(",
")",
";",
"$",
"thumb",
"->",
"setStatus",
"(",
"Media",
"::",
"STATUS_... | Save the thumbnail.
@param MediaInterface $media The Vimeo Object
@param string $url
@return MediaInterface The newly created image | [
"Save",
"the",
"thumbnail",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Provider/VimeoProvider.php#L153-L172 | train |
Opifer/Cms | src/CmsBundle/EventListener/FormSubmitListener.php | FormSubmitListener.postFormSubmit | public function postFormSubmit(FormSubmitEvent $event)
{
$post = $event->getPost();
$mailinglists = $email = null;
foreach ($post->getValueSet()->getValues() as $value) {
if ($value instanceof MailingListSubscribeValue && $value->getValue() == true) {
$parameters = $value->getAttribute()->getParameters();
if (isset($parameters['mailingLists'])) {
$mailinglists = $this->mailingListManager->getRepository()->findByIds($parameters['mailingLists']);
}
} elseif ($value instanceof EmailValue) {
$email = $value->getValue();
}
}
if ($email && $mailinglists) {
foreach ($mailinglists as $mailinglist) {
$subscription = new Subscription();
$subscription->setEmail($email);
$subscription->setMailingList($mailinglist);
$this->subscriptionManager->save($subscription);
}
}
} | php | public function postFormSubmit(FormSubmitEvent $event)
{
$post = $event->getPost();
$mailinglists = $email = null;
foreach ($post->getValueSet()->getValues() as $value) {
if ($value instanceof MailingListSubscribeValue && $value->getValue() == true) {
$parameters = $value->getAttribute()->getParameters();
if (isset($parameters['mailingLists'])) {
$mailinglists = $this->mailingListManager->getRepository()->findByIds($parameters['mailingLists']);
}
} elseif ($value instanceof EmailValue) {
$email = $value->getValue();
}
}
if ($email && $mailinglists) {
foreach ($mailinglists as $mailinglist) {
$subscription = new Subscription();
$subscription->setEmail($email);
$subscription->setMailingList($mailinglist);
$this->subscriptionManager->save($subscription);
}
}
} | [
"public",
"function",
"postFormSubmit",
"(",
"FormSubmitEvent",
"$",
"event",
")",
"{",
"$",
"post",
"=",
"$",
"event",
"->",
"getPost",
"(",
")",
";",
"$",
"mailinglists",
"=",
"$",
"email",
"=",
"null",
";",
"foreach",
"(",
"$",
"post",
"->",
"getVal... | This method is called right after the post is stored in the database during the Form submit.
@param FormSubmitEvent $event | [
"This",
"method",
"is",
"called",
"right",
"after",
"the",
"post",
"is",
"stored",
"in",
"the",
"database",
"during",
"the",
"Form",
"submit",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/EventListener/FormSubmitListener.php#L59-L85 | train |
oceanBigOne/MajorityJudgment | src/oceanBigOne/MajorityJudgment/Ballot.php | Ballot.initDefaultMentions | public function initDefaultMentions(): Ballot{
$this->mentions=[new Mention("Excellent"),new Mention("Good"),new Mention("Pretty good"),new Mention("Fair"),new Mention("Insufficient"),new Mention("To Reject")];
return $this;
} | php | public function initDefaultMentions(): Ballot{
$this->mentions=[new Mention("Excellent"),new Mention("Good"),new Mention("Pretty good"),new Mention("Fair"),new Mention("Insufficient"),new Mention("To Reject")];
return $this;
} | [
"public",
"function",
"initDefaultMentions",
"(",
")",
":",
"Ballot",
"{",
"$",
"this",
"->",
"mentions",
"=",
"[",
"new",
"Mention",
"(",
"\"Excellent\"",
")",
",",
"new",
"Mention",
"(",
"\"Good\"",
")",
",",
"new",
"Mention",
"(",
"\"Pretty good\"",
")"... | Set mentions width default values
@return Ballot | [
"Set",
"mentions",
"width",
"default",
"values"
] | eece81f04a28cd1bdea23acee3e62e9350a742c7 | https://github.com/oceanBigOne/MajorityJudgment/blob/eece81f04a28cd1bdea23acee3e62e9350a742c7/src/oceanBigOne/MajorityJudgment/Ballot.php#L46-L49 | train |
Opifer/Cms | src/ContentBundle/Entity/Block.php | Block.hasSharedParent | public function hasSharedParent()
{
$parent = $this->getParent();
if ($parent != null && ($parent->isShared() || $parent->hasSharedParent())) {
return true;
}
return false;
} | php | public function hasSharedParent()
{
$parent = $this->getParent();
if ($parent != null && ($parent->isShared() || $parent->hasSharedParent())) {
return true;
}
return false;
} | [
"public",
"function",
"hasSharedParent",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"!=",
"null",
"&&",
"(",
"$",
"parent",
"->",
"isShared",
"(",
")",
"||",
"$",
"parent",
"->",
"has... | Checks if one of the current blocks' parents is a shared block.
@return bool | [
"Checks",
"if",
"one",
"of",
"the",
"current",
"blocks",
"parents",
"is",
"a",
"shared",
"block",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Entity/Block.php#L604-L613 | train |
Opifer/Cms | src/ContentBundle/Helper/StringHelper.php | StringHelper.replaceLinks | public function replaceLinks($string)
{
preg_match_all('/(\[content_url\](.*?)\[\/content_url\]|\[content_url\](.*?)\[\\\\\/content_url\])/', $string, $matches);
if (!count($matches)) {
return $string;
}
if (!empty($matches[3][0])) {
$matches[1] = $matches[3];
} elseif (!empty($matches[2][0])) {
$matches[1] = $matches[2];
}
/** @var ContentInterface[] $contents */
$contents = $this->contentManager->getRepository()->findByIds($matches[1]);
$array = [];
foreach ($contents as $content) {
$array[$content->getId()] = $content;
}
foreach ($matches[0] as $key => $match) {
if (isset($array[$matches[1][$key]])) {
$content = $array[$matches[1][$key]];
$url = $this->router->generate('_content', ['slug' => $content->getSlug()]);
} else {
$url = $this->router->generate('_content', ['slug' => '404']);
}
$string = str_replace($match, $url, $string);
}
return $string;
} | php | public function replaceLinks($string)
{
preg_match_all('/(\[content_url\](.*?)\[\/content_url\]|\[content_url\](.*?)\[\\\\\/content_url\])/', $string, $matches);
if (!count($matches)) {
return $string;
}
if (!empty($matches[3][0])) {
$matches[1] = $matches[3];
} elseif (!empty($matches[2][0])) {
$matches[1] = $matches[2];
}
/** @var ContentInterface[] $contents */
$contents = $this->contentManager->getRepository()->findByIds($matches[1]);
$array = [];
foreach ($contents as $content) {
$array[$content->getId()] = $content;
}
foreach ($matches[0] as $key => $match) {
if (isset($array[$matches[1][$key]])) {
$content = $array[$matches[1][$key]];
$url = $this->router->generate('_content', ['slug' => $content->getSlug()]);
} else {
$url = $this->router->generate('_content', ['slug' => '404']);
}
$string = str_replace($match, $url, $string);
}
return $string;
} | [
"public",
"function",
"replaceLinks",
"(",
"$",
"string",
")",
"{",
"preg_match_all",
"(",
"'/(\\[content_url\\](.*?)\\[\\/content_url\\]|\\[content_url\\](.*?)\\[\\\\\\\\\\/content_url\\])/'",
",",
"$",
"string",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"count",
... | Replaces all links that matches the pattern with content urls.
@param string $string
@return string | [
"Replaces",
"all",
"links",
"that",
"matches",
"the",
"pattern",
"with",
"content",
"urls",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Helper/StringHelper.php#L28-L62 | train |
Opifer/Cms | src/ContentBundle/Form/DataTransformer/BoxModelDataTransformer.php | BoxModelDataTransformer.transform | public function transform($original)
{
if (!$original) {
return $original;
}
$string = substr($original, 1);
$split = explode('-', $string);
return [
'side' => $split[0],
'size' => $split[1],
];
} | php | public function transform($original)
{
if (!$original) {
return $original;
}
$string = substr($original, 1);
$split = explode('-', $string);
return [
'side' => $split[0],
'size' => $split[1],
];
} | [
"public",
"function",
"transform",
"(",
"$",
"original",
")",
"{",
"if",
"(",
"!",
"$",
"original",
")",
"{",
"return",
"$",
"original",
";",
"}",
"$",
"string",
"=",
"substr",
"(",
"$",
"original",
",",
"1",
")",
";",
"$",
"split",
"=",
"explode",... | Splits the string into the side- and size values
@param string|null $original
@return array|mixed | [
"Splits",
"the",
"string",
"into",
"the",
"side",
"-",
"and",
"size",
"values"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Form/DataTransformer/BoxModelDataTransformer.php#L30-L43 | train |
Opifer/Cms | src/ContentBundle/EventListener/BlockListener.php | BlockListener.getService | public function getService(LifecycleEventArgs $args)
{
$service = $args->getObject();
if (!$service) {
throw new \Exception('Please set a provider on the entity before persisting any media');
}
return $this->getBlockManager()->getService($service);
} | php | public function getService(LifecycleEventArgs $args)
{
$service = $args->getObject();
if (!$service) {
throw new \Exception('Please set a provider on the entity before persisting any media');
}
return $this->getBlockManager()->getService($service);
} | [
"public",
"function",
"getService",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
"{",
"$",
"service",
"=",
"$",
"args",
"->",
"getObject",
"(",
")",
";",
"if",
"(",
"!",
"$",
"service",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Please set a pro... | Get the service
@param LifecycleEventArgs $args
@return \Opifer\ContentBundle\Block\BlockServiceInterface
@throws \Exception | [
"Get",
"the",
"service"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/EventListener/BlockListener.php#L59-L68 | train |
Opifer/Cms | src/ContentBundle/Controller/Backend/ContentController.php | ContentController.createAction | public function createAction(Request $request, $siteId = null, $type = 0, $layoutId = null)
{
/** @var ContentManager $manager */
$manager = $this->get('opifer.content.content_manager');
if ($type) {
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
$content = $this->get('opifer.eav.eav_manager')->initializeEntity($contentType->getSchema());
$content->setContentType($contentType);
} else {
$content = $manager->initialize();
}
if ($siteId) {
$site = $this->getDoctrine()->getRepository(Site::class)->find($siteId);
//set siteId on content item
$content->setSite($site);
if ($site->getDefaultLocale()) {
$content->setLocale($site->getDefaultLocale());
}
}
$form = $this->createForm(ContentType::class, $content);
$form->handleRequest($request);
if ($form->isValid()) {
if ($layoutId) {
$duplicatedContent = $this->duplicateAction($layoutId, $content);
return $this->redirectToRoute('opifer_content_contenteditor_design', [
'owner' => 'content',
'ownerId' => $duplicatedContent->getId(),
]);
}
if (null === $content->getPublishAt()) {
$content->setPublishAt(new \DateTime());
}
$manager->save($content);
return $this->redirectToRoute('opifer_content_contenteditor_design', [
'owner' => 'content',
'ownerId' => $content->getId(),
'site_id' => $siteId
]);
}
return $this->render($this->getParameter('opifer_content.content_new_view'), [
'form' => $form->createView(),
]);
} | php | public function createAction(Request $request, $siteId = null, $type = 0, $layoutId = null)
{
/** @var ContentManager $manager */
$manager = $this->get('opifer.content.content_manager');
if ($type) {
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
$content = $this->get('opifer.eav.eav_manager')->initializeEntity($contentType->getSchema());
$content->setContentType($contentType);
} else {
$content = $manager->initialize();
}
if ($siteId) {
$site = $this->getDoctrine()->getRepository(Site::class)->find($siteId);
//set siteId on content item
$content->setSite($site);
if ($site->getDefaultLocale()) {
$content->setLocale($site->getDefaultLocale());
}
}
$form = $this->createForm(ContentType::class, $content);
$form->handleRequest($request);
if ($form->isValid()) {
if ($layoutId) {
$duplicatedContent = $this->duplicateAction($layoutId, $content);
return $this->redirectToRoute('opifer_content_contenteditor_design', [
'owner' => 'content',
'ownerId' => $duplicatedContent->getId(),
]);
}
if (null === $content->getPublishAt()) {
$content->setPublishAt(new \DateTime());
}
$manager->save($content);
return $this->redirectToRoute('opifer_content_contenteditor_design', [
'owner' => 'content',
'ownerId' => $content->getId(),
'site_id' => $siteId
]);
}
return $this->render($this->getParameter('opifer_content.content_new_view'), [
'form' => $form->createView(),
]);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
",",
"$",
"siteId",
"=",
"null",
",",
"$",
"type",
"=",
"0",
",",
"$",
"layoutId",
"=",
"null",
")",
"{",
"/** @var ContentManager $manager */",
"$",
"manager",
"=",
"$",
"this",
"->",
... | Create a new content item.
@param Request $request
@param int $type
@return Response | [
"Create",
"a",
"new",
"content",
"item",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/ContentController.php#L162-L214 | train |
Opifer/Cms | src/ContentBundle/Controller/Backend/ContentController.php | ContentController.editAction | public function editAction(Request $request, $id)
{
/** @var ContentManager $manager */
$manager = $this->get('opifer.content.content_manager');
$em = $manager->getEntityManager();
$content = $manager->getRepository()->find($id);
$content = $manager->createMissingValueSet($content);
// Load the contentTranslations for the content group
if ($content->getTranslationGroup() !== null) {
$contentTranslations = $content->getTranslationGroup()->getContents()->filter(function($contentTranslation) use ($content) {
return $contentTranslation->getId() !== $content->getId();
});
$content->setContentTranslations($contentTranslations);
}
$form = $this->createForm(ContentType::class, $content);
$originalContentItems = new ArrayCollection();
foreach ($content->getContentTranslations() as $contentItem) {
$originalContentItems->add($contentItem);
}
$form->handleRequest($request);
if ($form->isValid()) {
if (null === $content->getPublishAt()) {
$content->setPublishAt($content->getCreatedAt());
}
if ($content->getTranslationGroup() === null) {
// Init new group
$translationGroup = new TranslationGroup();
$content->setTranslationGroup($translationGroup);
}
// Make sure all the contentTranslations have the same group as content
$contentTranslationIds = [$content->getId()];
foreach($content->getContentTranslations() as $contentTranslation) {
if ($contentTranslation->getTranslationGroup() === null) {
$contentTranslation->setTranslationGroup($content->getTranslationGroup());
$em->persist($contentTranslation);
}
$contentTranslationIds[] = $contentTranslation->getId();
}
// Remove possible contentTranslations from the translationGroup
$queryBuilder = $manager->getRepository()->createQueryBuilder('c');
$queryBuilder->update()
->set('c.translationGroup', 'NULL')
->where($queryBuilder->expr()->eq('c.translationGroup', $content->getTranslationGroup()->getId()))
->where($queryBuilder->expr()->notIn('c.id', $contentTranslationIds))
->getQuery()
->execute();
$em->persist($content);
$em->flush();
return $this->redirectToRoute('opifer_content_content_index');
}
return $this->render($this->getParameter('opifer_content.content_edit_view'), [
'content' => $content,
'form' => $form->createView(),
]);
} | php | public function editAction(Request $request, $id)
{
/** @var ContentManager $manager */
$manager = $this->get('opifer.content.content_manager');
$em = $manager->getEntityManager();
$content = $manager->getRepository()->find($id);
$content = $manager->createMissingValueSet($content);
// Load the contentTranslations for the content group
if ($content->getTranslationGroup() !== null) {
$contentTranslations = $content->getTranslationGroup()->getContents()->filter(function($contentTranslation) use ($content) {
return $contentTranslation->getId() !== $content->getId();
});
$content->setContentTranslations($contentTranslations);
}
$form = $this->createForm(ContentType::class, $content);
$originalContentItems = new ArrayCollection();
foreach ($content->getContentTranslations() as $contentItem) {
$originalContentItems->add($contentItem);
}
$form->handleRequest($request);
if ($form->isValid()) {
if (null === $content->getPublishAt()) {
$content->setPublishAt($content->getCreatedAt());
}
if ($content->getTranslationGroup() === null) {
// Init new group
$translationGroup = new TranslationGroup();
$content->setTranslationGroup($translationGroup);
}
// Make sure all the contentTranslations have the same group as content
$contentTranslationIds = [$content->getId()];
foreach($content->getContentTranslations() as $contentTranslation) {
if ($contentTranslation->getTranslationGroup() === null) {
$contentTranslation->setTranslationGroup($content->getTranslationGroup());
$em->persist($contentTranslation);
}
$contentTranslationIds[] = $contentTranslation->getId();
}
// Remove possible contentTranslations from the translationGroup
$queryBuilder = $manager->getRepository()->createQueryBuilder('c');
$queryBuilder->update()
->set('c.translationGroup', 'NULL')
->where($queryBuilder->expr()->eq('c.translationGroup', $content->getTranslationGroup()->getId()))
->where($queryBuilder->expr()->notIn('c.id', $contentTranslationIds))
->getQuery()
->execute();
$em->persist($content);
$em->flush();
return $this->redirectToRoute('opifer_content_content_index');
}
return $this->render($this->getParameter('opifer_content.content_edit_view'), [
'content' => $content,
'form' => $form->createView(),
]);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"/** @var ContentManager $manager */",
"$",
"manager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.content_manager'",
")",
";",
"$",
"em",
"=",
"$",
"manager... | Edit the details of Content.
@param Request $request
@param int $id
@return Response | [
"Edit",
"the",
"details",
"of",
"Content",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/ContentController.php#L263-L331 | train |
Opifer/Cms | src/MediaBundle/EventListener/Serializer/MediaEventSubscriber.php | MediaEventSubscriber.onPostSerialize | public function onPostSerialize(ObjectEvent $event)
{
// getSubscribedEvents doesn't seem to support parent classes
if (!$event->getObject() instanceof MediaInterface) {
return;
}
/** @var MediaInterface $media */
$media = $event->getObject();
$provider = $this->getProvider($media);
if ($provider->getName() == 'image') {
$images = $this->getImages($media, ['medialibrary']);
$event->getVisitor()->addData('images', $images);
}
$event->getVisitor()->addData('original', $provider->getUrl($media));
} | php | public function onPostSerialize(ObjectEvent $event)
{
// getSubscribedEvents doesn't seem to support parent classes
if (!$event->getObject() instanceof MediaInterface) {
return;
}
/** @var MediaInterface $media */
$media = $event->getObject();
$provider = $this->getProvider($media);
if ($provider->getName() == 'image') {
$images = $this->getImages($media, ['medialibrary']);
$event->getVisitor()->addData('images', $images);
}
$event->getVisitor()->addData('original', $provider->getUrl($media));
} | [
"public",
"function",
"onPostSerialize",
"(",
"ObjectEvent",
"$",
"event",
")",
"{",
"// getSubscribedEvents doesn't seem to support parent classes",
"if",
"(",
"!",
"$",
"event",
"->",
"getObject",
"(",
")",
"instanceof",
"MediaInterface",
")",
"{",
"return",
";",
... | Listens to the post_serialize event and generates urls to the different image formats.
@param ObjectEvent $event | [
"Listens",
"to",
"the",
"post_serialize",
"event",
"and",
"generates",
"urls",
"to",
"the",
"different",
"image",
"formats",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/EventListener/Serializer/MediaEventSubscriber.php#L67-L86 | train |
Opifer/Cms | src/MediaBundle/EventListener/Serializer/MediaEventSubscriber.php | MediaEventSubscriber.getImages | public function getImages(MediaInterface $media, array $filters)
{
$key = $media->getImagesCacheKey();
if (!$images = $this->cache->fetch($key)) {
$provider = $this->getProvider($media);
$reference = $provider->getThumb($media);
$images = [];
foreach ($filters as $filter) {
if ($media->getContentType() == 'image/svg+xml') {
$images[$filter] = $provider->getUrl($media);
} else {
$images[$filter] = $this->cacheManager->getBrowserPath($reference, $filter);
}
}
$this->cache->save($key, $images, 0);
}
return $images;
} | php | public function getImages(MediaInterface $media, array $filters)
{
$key = $media->getImagesCacheKey();
if (!$images = $this->cache->fetch($key)) {
$provider = $this->getProvider($media);
$reference = $provider->getThumb($media);
$images = [];
foreach ($filters as $filter) {
if ($media->getContentType() == 'image/svg+xml') {
$images[$filter] = $provider->getUrl($media);
} else {
$images[$filter] = $this->cacheManager->getBrowserPath($reference, $filter);
}
}
$this->cache->save($key, $images, 0);
}
return $images;
} | [
"public",
"function",
"getImages",
"(",
"MediaInterface",
"$",
"media",
",",
"array",
"$",
"filters",
")",
"{",
"$",
"key",
"=",
"$",
"media",
"->",
"getImagesCacheKey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"images",
"=",
"$",
"this",
"->",
"cache",
"... | Gets the cached images if any. If the cache is not present, it generates images for all filters.
@param MediaInterface $media
@param array $filters
@return MediaInterface[] | [
"Gets",
"the",
"cached",
"images",
"if",
"any",
".",
"If",
"the",
"cache",
"is",
"not",
"present",
"it",
"generates",
"images",
"for",
"all",
"filters",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/EventListener/Serializer/MediaEventSubscriber.php#L96-L117 | train |
Opifer/Cms | src/ContentBundle/Block/Service/RelatedCollectionBlockService.php | RelatedCollectionBlockService.getAttributes | protected function getAttributes(ContentInterface $owner)
{
/** @var AttributeInterface $attributes */
$attributes = $owner->getValueSet()->getAttributes();
$choices = [];
foreach ($attributes as $attribute) {
if (!in_array($attribute->getValueType(), ['select', 'radio', 'checklist'])) {
continue;
}
$choices[$attribute->getDisplayName()] = $attribute->getName();
}
return $choices;
} | php | protected function getAttributes(ContentInterface $owner)
{
/** @var AttributeInterface $attributes */
$attributes = $owner->getValueSet()->getAttributes();
$choices = [];
foreach ($attributes as $attribute) {
if (!in_array($attribute->getValueType(), ['select', 'radio', 'checklist'])) {
continue;
}
$choices[$attribute->getDisplayName()] = $attribute->getName();
}
return $choices;
} | [
"protected",
"function",
"getAttributes",
"(",
"ContentInterface",
"$",
"owner",
")",
"{",
"/** @var AttributeInterface $attributes */",
"$",
"attributes",
"=",
"$",
"owner",
"->",
"getValueSet",
"(",
")",
"->",
"getAttributes",
"(",
")",
";",
"$",
"choices",
"=",... | Get the selectable attributes
@param ContentInterface $owner
@return array | [
"Get",
"the",
"selectable",
"attributes"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/Service/RelatedCollectionBlockService.php#L54-L68 | train |
Opifer/Cms | src/FormBundle/Controller/PostController.php | PostController.viewAction | public function viewAction($id)
{
$post = $this->get('opifer.form.post_manager')->getRepository()->find($id);
if (!$post) {
return $this->createNotFoundException();
}
return $this->render($this->getParameter('opifer_form.post_view_view'), [
'post' => $post,
]);
} | php | public function viewAction($id)
{
$post = $this->get('opifer.form.post_manager')->getRepository()->find($id);
if (!$post) {
return $this->createNotFoundException();
}
return $this->render($this->getParameter('opifer_form.post_view_view'), [
'post' => $post,
]);
} | [
"public",
"function",
"viewAction",
"(",
"$",
"id",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.post_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"post",
... | View a form post.
@param int $id
@return Response | [
"View",
"a",
"form",
"post",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/PostController.php#L40-L51 | train |
Opifer/Cms | src/FormBundle/Controller/PostController.php | PostController.notificationAction | public function notificationAction($id)
{
/** @var PostInterface $post */
$post = $this->get('opifer.form.post_manager')->getRepository()->find($id);
if (!$post) {
return $this->createNotFoundException();
}
$form = $post->getForm();
/** @var Mailer $mailer */
$mailer = $this->get('opifer.form.mailer');
$mailer->sendNotificationMail($form, $post);
$this->addFlash('success', 'Notification mail sent successfully');
return $this->redirectToRoute('opifer_form_post_index', ['formId' => $form->getId()]);
} | php | public function notificationAction($id)
{
/** @var PostInterface $post */
$post = $this->get('opifer.form.post_manager')->getRepository()->find($id);
if (!$post) {
return $this->createNotFoundException();
}
$form = $post->getForm();
/** @var Mailer $mailer */
$mailer = $this->get('opifer.form.mailer');
$mailer->sendNotificationMail($form, $post);
$this->addFlash('success', 'Notification mail sent successfully');
return $this->redirectToRoute('opifer_form_post_index', ['formId' => $form->getId()]);
} | [
"public",
"function",
"notificationAction",
"(",
"$",
"id",
")",
"{",
"/** @var PostInterface $post */",
"$",
"post",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.post_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
"... | Re-sends a notification email for the given form post
@param int $id
@return RedirectResponse|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException | [
"Re",
"-",
"sends",
"a",
"notification",
"email",
"for",
"the",
"given",
"form",
"post"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/PostController.php#L84-L102 | train |
Opifer/Cms | src/CmsBundle/Manager/ConfigManager.php | ConfigManager.keyValues | public function keyValues($form = null)
{
if (null === $this->configs) {
$this->loadConfigs();
}
$keys = ($form) ? call_user_func([$form, 'getFields']) : [];
$array = [];
foreach ($this->configs as $key => $config) {
if ($form && !in_array($key, $keys)) {
continue;
}
$array[$key] = $config->getValue();
}
return $array;
} | php | public function keyValues($form = null)
{
if (null === $this->configs) {
$this->loadConfigs();
}
$keys = ($form) ? call_user_func([$form, 'getFields']) : [];
$array = [];
foreach ($this->configs as $key => $config) {
if ($form && !in_array($key, $keys)) {
continue;
}
$array[$key] = $config->getValue();
}
return $array;
} | [
"public",
"function",
"keyValues",
"(",
"$",
"form",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"configs",
")",
"{",
"$",
"this",
"->",
"loadConfigs",
"(",
")",
";",
"}",
"$",
"keys",
"=",
"(",
"$",
"form",
")",
"?",
"c... | Returns a key-value array of the settings.
@param string $form
@return array | [
"Returns",
"a",
"key",
"-",
"value",
"array",
"of",
"the",
"settings",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Manager/ConfigManager.php#L145-L163 | train |
Opifer/Cms | src/CmsBundle/Manager/ConfigManager.php | ConfigManager.loadConfigs | public function loadConfigs()
{
$configs = [];
foreach ($this->getRepository()->findAll() as $config) {
$configs[$config->getName()] = $config;
}
$this->configs = $configs;
return $configs;
} | php | public function loadConfigs()
{
$configs = [];
foreach ($this->getRepository()->findAll() as $config) {
$configs[$config->getName()] = $config;
}
$this->configs = $configs;
return $configs;
} | [
"public",
"function",
"loadConfigs",
"(",
")",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"findAll",
"(",
")",
"as",
"$",
"config",
")",
"{",
"$",
"configs",
"[",
"$",
"config",
"->"... | Retrieve the configs and converts them for later use. | [
"Retrieve",
"the",
"configs",
"and",
"converts",
"them",
"for",
"later",
"use",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Manager/ConfigManager.php#L188-L198 | train |
Opifer/Cms | src/FormBundle/Controller/FormController.php | FormController.indexAction | public function indexAction()
{
$forms = $this->get('opifer.form.form_manager')->getRepository()
->findAllWithPosts();
return $this->render($this->getParameter('opifer_form.form_index_view'), [
'forms' => $forms,
]);
} | php | public function indexAction()
{
$forms = $this->get('opifer.form.form_manager')->getRepository()
->findAllWithPosts();
return $this->render($this->getParameter('opifer_form.form_index_view'), [
'forms' => $forms,
]);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"forms",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.form_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"findAllWithPosts",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
... | Form index view.
The template defaults to `OpiferFormBundle:Form:index.html.twig`, but can easily be overwritten
in the bundle configuration.
@return Response | [
"Form",
"index",
"view",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/FormController.php#L27-L35 | train |
Opifer/Cms | src/FormBundle/Controller/FormController.php | FormController.createAction | public function createAction(Request $request)
{
$formManager = $this->get('opifer.form.form_manager');
$form = $formManager->create();
$formType = $this->createForm(FormType::class, $form);
$formType->handleRequest($request);
if ($formType->isSubmitted() && $formType->isValid()) {
foreach ($formType->getData()->getSchema()->getAttributes() as $attribute) {
$attribute->setSchema($form->getSchema());
foreach ($attribute->getOptions() as $option) {
$option->setAttribute($attribute);
}
}
$formManager->save($form);
$this->addFlash('success', 'Form has been created successfully');
return $this->redirectToRoute('opifer_form_form_edit', ['id' => $form->getId()]);
}
return $this->render($this->getParameter('opifer_form.form_create_view'), [
'form' => $form,
'form_form' => $formType->createView(),
]);
} | php | public function createAction(Request $request)
{
$formManager = $this->get('opifer.form.form_manager');
$form = $formManager->create();
$formType = $this->createForm(FormType::class, $form);
$formType->handleRequest($request);
if ($formType->isSubmitted() && $formType->isValid()) {
foreach ($formType->getData()->getSchema()->getAttributes() as $attribute) {
$attribute->setSchema($form->getSchema());
foreach ($attribute->getOptions() as $option) {
$option->setAttribute($attribute);
}
}
$formManager->save($form);
$this->addFlash('success', 'Form has been created successfully');
return $this->redirectToRoute('opifer_form_form_edit', ['id' => $form->getId()]);
}
return $this->render($this->getParameter('opifer_form.form_create_view'), [
'form' => $form,
'form_form' => $formType->createView(),
]);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"formManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.form_manager'",
")",
";",
"$",
"form",
"=",
"$",
"formManager",
"->",
"create",
"(",
")",
";",
"$",
"for... | Create a form.
@param Request $request
@return RedirectResponse|Response | [
"Create",
"a",
"form",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/FormController.php#L44-L73 | train |
Opifer/Cms | src/FormBundle/Controller/FormController.php | FormController.editAction | public function editAction(Request $request, $id)
{
$formManager = $this->get('opifer.form.form_manager');
$em = $this->get('doctrine.orm.entity_manager');
$form = $formManager->getRepository()->find($id);
if (!$form) {
return $this->createNotFoundException();
}
$originalAttributes = new ArrayCollection();
foreach ($form->getSchema()->getAttributes() as $attributes) {
$originalAttributes->add($attributes);
}
$formType = $this->createForm(FormType::class, $form);
$formType->handleRequest($request);
if ($formType->isSubmitted() && $formType->isValid()) {
// Remove deleted attributes
foreach ($originalAttributes as $attribute) {
if (false === $form->getSchema()->getAttributes()->contains($attribute)) {
$em->remove($attribute);
}
}
// Add new attributes
foreach ($formType->getData()->getSchema()->getAttributes() as $attribute) {
$attribute->setSchema($form->getSchema());
foreach ($attribute->getOptions() as $option) {
$option->setAttribute($attribute);
}
}
$formManager->save($form);
$this->addFlash('success', 'Event has been updated successfully');
return $this->redirectToRoute('opifer_form_form_edit', ['id' => $form->getId()]);
}
return $this->render($this->getParameter('opifer_form.form_edit_view'), [
'form' => $form,
'form_form' => $formType->createView(),
]);
} | php | public function editAction(Request $request, $id)
{
$formManager = $this->get('opifer.form.form_manager');
$em = $this->get('doctrine.orm.entity_manager');
$form = $formManager->getRepository()->find($id);
if (!$form) {
return $this->createNotFoundException();
}
$originalAttributes = new ArrayCollection();
foreach ($form->getSchema()->getAttributes() as $attributes) {
$originalAttributes->add($attributes);
}
$formType = $this->createForm(FormType::class, $form);
$formType->handleRequest($request);
if ($formType->isSubmitted() && $formType->isValid()) {
// Remove deleted attributes
foreach ($originalAttributes as $attribute) {
if (false === $form->getSchema()->getAttributes()->contains($attribute)) {
$em->remove($attribute);
}
}
// Add new attributes
foreach ($formType->getData()->getSchema()->getAttributes() as $attribute) {
$attribute->setSchema($form->getSchema());
foreach ($attribute->getOptions() as $option) {
$option->setAttribute($attribute);
}
}
$formManager->save($form);
$this->addFlash('success', 'Event has been updated successfully');
return $this->redirectToRoute('opifer_form_form_edit', ['id' => $form->getId()]);
}
return $this->render($this->getParameter('opifer_form.form_edit_view'), [
'form' => $form,
'form_form' => $formType->createView(),
]);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"formManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.form.form_manager'",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"get",
"(",
"'doctrine.orm.en... | Edit a form.
@param Request $request
@param int $id
@return RedirectResponse|Response | [
"Edit",
"a",
"form",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Controller/FormController.php#L83-L130 | train |
Opifer/Cms | src/ContentBundle/Controller/Frontend/ContentController.php | ContentController.homeAction | public function homeAction(Request $request)
{
/** @var BlockManager $manager */
$manager = $this->get('opifer.content.content_manager');
$host = $request->getHost();
$em = $this->getDoctrine()->getManager();
$siteCount = $em->getRepository(Site::class)->createQueryBuilder('s')
->select('count(s.id)')
->getQuery()
->getSingleScalarResult();
$domain = $em->getRepository(Domain::class)->findOneByDomain($host);
if ($siteCount && $domain->getSite()->getDefaultLocale()) {
$request->setLocale($domain->getSite()->getDefaultLocale()->getLocale());
}
if (!$domain && $siteCount > 1) {
return $this->render('OpiferContentBundle:Content:domain_not_found.html.twig');
}
$content = $manager->getRepository()->findActiveBySlug('index', $host);
return $this->forward('OpiferContentBundle:Frontend/Content:view', [
'content' => $content
]);
} | php | public function homeAction(Request $request)
{
/** @var BlockManager $manager */
$manager = $this->get('opifer.content.content_manager');
$host = $request->getHost();
$em = $this->getDoctrine()->getManager();
$siteCount = $em->getRepository(Site::class)->createQueryBuilder('s')
->select('count(s.id)')
->getQuery()
->getSingleScalarResult();
$domain = $em->getRepository(Domain::class)->findOneByDomain($host);
if ($siteCount && $domain->getSite()->getDefaultLocale()) {
$request->setLocale($domain->getSite()->getDefaultLocale()->getLocale());
}
if (!$domain && $siteCount > 1) {
return $this->render('OpiferContentBundle:Content:domain_not_found.html.twig');
}
$content = $manager->getRepository()->findActiveBySlug('index', $host);
return $this->forward('OpiferContentBundle:Frontend/Content:view', [
'content' => $content
]);
} | [
"public",
"function",
"homeAction",
"(",
"Request",
"$",
"request",
")",
"{",
"/** @var BlockManager $manager */",
"$",
"manager",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.content_manager'",
")",
";",
"$",
"host",
"=",
"$",
"request",
"->",
"getHost"... | Render the home page.
@param Request $request
@return Response | [
"Render",
"the",
"home",
"page",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Frontend/ContentController.php#L101-L128 | train |
aegis-security/JWT | src/Parser.php | Parser.parse | public function parse($jwt)
{
$data = $this->splitJwt($jwt);
$header = $this->parseHeader($data[0]);
$claims = $this->parseClaims($data[1]);
$signature = $this->parseSignature($header, $data[2]);
foreach ($claims as $name => $value) {
if (isset($header[$name])) {
$header[$name] = $value;
}
}
if ($signature === null) {
unset($data[2]);
}
return new Token($header, $claims, $signature, $data);
} | php | public function parse($jwt)
{
$data = $this->splitJwt($jwt);
$header = $this->parseHeader($data[0]);
$claims = $this->parseClaims($data[1]);
$signature = $this->parseSignature($header, $data[2]);
foreach ($claims as $name => $value) {
if (isset($header[$name])) {
$header[$name] = $value;
}
}
if ($signature === null) {
unset($data[2]);
}
return new Token($header, $claims, $signature, $data);
} | [
"public",
"function",
"parse",
"(",
"$",
"jwt",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"splitJwt",
"(",
"$",
"jwt",
")",
";",
"$",
"header",
"=",
"$",
"this",
"->",
"parseHeader",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"$",
"claims"... | Parses the JWT and returns a token
@param string $jwt
@return Token | [
"Parses",
"the",
"JWT",
"and",
"returns",
"a",
"token"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Parser.php#L53-L71 | train |
aegis-security/JWT | src/Parser.php | Parser.splitJwt | protected function splitJwt($jwt)
{
if (!is_string($jwt)) {
throw new \InvalidArgumentException('The JWT string must have two dots');
}
$data = explode('.', $jwt);
if (count($data) != 3) {
throw new \InvalidArgumentException('The JWT string must have two dots');
}
return $data;
} | php | protected function splitJwt($jwt)
{
if (!is_string($jwt)) {
throw new \InvalidArgumentException('The JWT string must have two dots');
}
$data = explode('.', $jwt);
if (count($data) != 3) {
throw new \InvalidArgumentException('The JWT string must have two dots');
}
return $data;
} | [
"protected",
"function",
"splitJwt",
"(",
"$",
"jwt",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"jwt",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The JWT string must have two dots'",
")",
";",
"}",
"$",
"data",
"=",
"exp... | Splits the JWT string into an array
@param string $jwt
@return array
@throws \InvalidArgumentException When JWT is not a string or is invalid | [
"Splits",
"the",
"JWT",
"string",
"into",
"an",
"array"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Parser.php#L82-L95 | train |
aegis-security/JWT | src/Parser.php | Parser.parseHeader | protected function parseHeader($data)
{
$header = (array) $this->deserializer->fromJSON($this->deserializer->fromBase64URL($data));
if (isset($header['enc'])) {
throw new \InvalidArgumentException('Encryption is not supported yet');
}
return $header;
} | php | protected function parseHeader($data)
{
$header = (array) $this->deserializer->fromJSON($this->deserializer->fromBase64URL($data));
if (isset($header['enc'])) {
throw new \InvalidArgumentException('Encryption is not supported yet');
}
return $header;
} | [
"protected",
"function",
"parseHeader",
"(",
"$",
"data",
")",
"{",
"$",
"header",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"deserializer",
"->",
"fromJSON",
"(",
"$",
"this",
"->",
"deserializer",
"->",
"fromBase64URL",
"(",
"$",
"data",
")",
")",
"... | Parses the header from a string
@param string $data
@return array
@throws \InvalidArgumentException When an invalid header is informed | [
"Parses",
"the",
"header",
"from",
"a",
"string"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Parser.php#L106-L115 | train |
aegis-security/JWT | src/Parser.php | Parser.parseClaims | protected function parseClaims($data)
{
$claims = (array) $this->deserializer->fromJSON($this->deserializer->fromBase64URL($data));
foreach ($claims as $name => &$value) {
$value = $this->claimFactory->create($name, $value);
}
return $claims;
} | php | protected function parseClaims($data)
{
$claims = (array) $this->deserializer->fromJSON($this->deserializer->fromBase64URL($data));
foreach ($claims as $name => &$value) {
$value = $this->claimFactory->create($name, $value);
}
return $claims;
} | [
"protected",
"function",
"parseClaims",
"(",
"$",
"data",
")",
"{",
"$",
"claims",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"deserializer",
"->",
"fromJSON",
"(",
"$",
"this",
"->",
"deserializer",
"->",
"fromBase64URL",
"(",
"$",
"data",
")",
")",
"... | Parses the claim set from a string
@param string $data
@return array | [
"Parses",
"the",
"claim",
"set",
"from",
"a",
"string"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Parser.php#L124-L133 | train |
aegis-security/JWT | src/Parser.php | Parser.parseSignature | protected function parseSignature(array $header, $data)
{
if ($data == '' || !isset($header['alg']) || $header['alg'] == 'none') {
return null;
}
$hash = $this->deserializer->fromBase64URL($data);
return new Signature($hash);
} | php | protected function parseSignature(array $header, $data)
{
if ($data == '' || !isset($header['alg']) || $header['alg'] == 'none') {
return null;
}
$hash = $this->deserializer->fromBase64URL($data);
return new Signature($hash);
} | [
"protected",
"function",
"parseSignature",
"(",
"array",
"$",
"header",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"==",
"''",
"||",
"!",
"isset",
"(",
"$",
"header",
"[",
"'alg'",
"]",
")",
"||",
"$",
"header",
"[",
"'alg'",
"]",
"==",
... | Returns the signature from given data
@param array $header
@param string $data
@return Signature | [
"Returns",
"the",
"signature",
"from",
"given",
"data"
] | b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23 | https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Parser.php#L143-L152 | train |
Opifer/Cms | src/ContentBundle/Model/Content.php | Content.getBaseSlug | public function getBaseSlug()
{
$slug = $this->slug;
if (substr($slug, -6) == '/index') {
$slug = rtrim($slug, 'index');
}
return $slug;
} | php | public function getBaseSlug()
{
$slug = $this->slug;
if (substr($slug, -6) == '/index') {
$slug = rtrim($slug, 'index');
}
return $slug;
} | [
"public",
"function",
"getBaseSlug",
"(",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"slug",
";",
"if",
"(",
"substr",
"(",
"$",
"slug",
",",
"-",
"6",
")",
"==",
"'/index'",
")",
"{",
"$",
"slug",
"=",
"rtrim",
"(",
"$",
"slug",
",",
"'ind... | Get slug without index appended.
@return string | [
"Get",
"slug",
"without",
"index",
"appended",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/Content.php#L427-L436 | train |
Opifer/Cms | src/ContentBundle/Model/Content.php | Content.getBreadCrumbs | public function getBreadCrumbs()
{
$crumbs = [];
if (null !== $this->parent) {
$crumbs = $this->getParent()->getBreadCrumbs();
}
$crumbs[$this->slug] = $this->getShortTitle();
return $crumbs;
} | php | public function getBreadCrumbs()
{
$crumbs = [];
if (null !== $this->parent) {
$crumbs = $this->getParent()->getBreadCrumbs();
}
$crumbs[$this->slug] = $this->getShortTitle();
return $crumbs;
} | [
"public",
"function",
"getBreadCrumbs",
"(",
")",
"{",
"$",
"crumbs",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"parent",
")",
"{",
"$",
"crumbs",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getBreadCrumbs",
"(",
")... | Get breadcrumbs.
Loops through all parents to determine the breadcrumbs and stores them in
an associative array like [slug => label]
@return array | [
"Get",
"breadcrumbs",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/Content.php#L1062-L1073 | train |
Opifer/Cms | src/ContentBundle/Model/Content.php | Content.getParents | public function getParents($includeSelf = true)
{
$parents = [];
if (null !== $this->parent) {
$parents = $this->getParent()->getParents();
}
if ($includeSelf) {
$parents[] = $this;
}
return $parents;
} | php | public function getParents($includeSelf = true)
{
$parents = [];
if (null !== $this->parent) {
$parents = $this->getParent()->getParents();
}
if ($includeSelf) {
$parents[] = $this;
}
return $parents;
} | [
"public",
"function",
"getParents",
"(",
"$",
"includeSelf",
"=",
"true",
")",
"{",
"$",
"parents",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"parent",
")",
"{",
"$",
"parents",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
... | Get all parents of the current content item
@param bool $includeSelf
@return ContentInterface[] | [
"Get",
"all",
"parents",
"of",
"the",
"current",
"content",
"item"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/Content.php#L1082-L1095 | train |
Opifer/Cms | src/ContentBundle/Model/Content.php | Content.getCoverImage | public function getCoverImage()
{
if ($this->getValueSet() !== null) {
foreach ($this->getValueSet()->getValues() as $value) {
if ($value instanceof MediaValue &&
false !== $media = $value->getMedias()->first()) {
return $media->getReference();
}
}
}
foreach ($this->getBlocks() as $block) {
$reflect = new \ReflectionClass($block);
if ($reflect->hasProperty('media') && $block->getMedia()) {
return $block->getMedia()->getReference();
}
}
return false;
} | php | public function getCoverImage()
{
if ($this->getValueSet() !== null) {
foreach ($this->getValueSet()->getValues() as $value) {
if ($value instanceof MediaValue &&
false !== $media = $value->getMedias()->first()) {
return $media->getReference();
}
}
}
foreach ($this->getBlocks() as $block) {
$reflect = new \ReflectionClass($block);
if ($reflect->hasProperty('media') && $block->getMedia()) {
return $block->getMedia()->getReference();
}
}
return false;
} | [
"public",
"function",
"getCoverImage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getValueSet",
"(",
")",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getValueSet",
"(",
")",
"->",
"getValues",
"(",
")",
"as",
"$",
"value",
")",
... | Finds first available image for listing purposes.
@return bool | [
"Finds",
"first",
"available",
"image",
"for",
"listing",
"purposes",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/Content.php#L1146-L1166 | train |
oRastor/jira-client | src/Resource/Field.php | Field.getCustomFieldOption | public static function getCustomFieldOption(JiraClient $client, $id)
{
$path = "/customFieldOption/{$id}";
try {
$data = $client->callGet($path)->getData();
$data['id'] = $id;
return new CustomFieldOption($client, $data);
} catch (Exception $e) {
throw new JiraException("Failed to get custom field option", $e);
}
} | php | public static function getCustomFieldOption(JiraClient $client, $id)
{
$path = "/customFieldOption/{$id}";
try {
$data = $client->callGet($path)->getData();
$data['id'] = $id;
return new CustomFieldOption($client, $data);
} catch (Exception $e) {
throw new JiraException("Failed to get custom field option", $e);
}
} | [
"public",
"static",
"function",
"getCustomFieldOption",
"(",
"JiraClient",
"$",
"client",
",",
"$",
"id",
")",
"{",
"$",
"path",
"=",
"\"/customFieldOption/{$id}\"",
";",
"try",
"{",
"$",
"data",
"=",
"$",
"client",
"->",
"callGet",
"(",
"$",
"path",
")",
... | Returns a full representation of the Custom Field Option that has the given id.
@param JiraClient $client
@param int $id
@return \JiraClient\Resource\CustomFieldOption
@throws JiraException | [
"Returns",
"a",
"full",
"representation",
"of",
"the",
"Custom",
"Field",
"Option",
"that",
"has",
"the",
"given",
"id",
"."
] | dabb4ddaad0005c53f69df073aa24d319af2be90 | https://github.com/oRastor/jira-client/blob/dabb4ddaad0005c53f69df073aa24d319af2be90/src/Resource/Field.php#L176-L188 | train |
Opifer/Cms | src/CmsBundle/CmsKernel.php | CmsKernel.registerBundles | public function registerBundles()
{
$bundles = [
// Symfony standard bundles
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// Added vendor bundles
new \APY\DataGridBundle\APYDataGridBundle(),
new \Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
new \Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle(),
new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new \FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\UserBundle\FOSUserBundle(),
new \JMS\SerializerBundle\JMSSerializerBundle(),
new \Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
new \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
new \Lexik\Bundle\TranslationBundle\LexikTranslationBundle(),
new \Liip\ImagineBundle\LiipImagineBundle(),
new \Limenius\LiformBundle\LimeniusLiformBundle(),
new \Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new \Nelmio\CorsBundle\NelmioCorsBundle(),
new \Scheb\TwoFactorBundle\SchebTwoFactorBundle(),
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
// Opifer bundles
new \Opifer\CmsBundle\OpiferCmsBundle(),
new \Opifer\ContentBundle\OpiferContentBundle(),
new \Opifer\EavBundle\OpiferEavBundle(),
new \Opifer\FormBundle\OpiferFormBundle(),
new \Opifer\FormBlockBundle\OpiferFormBlockBundle(),
new \Opifer\MediaBundle\OpiferMediaBundle(),
new \Opifer\RedirectBundle\OpiferRedirectBundle(),
new \Opifer\ReviewBundle\OpiferReviewBundle(),
new \Opifer\MailingListBundle\OpiferMailingListBundle(),
new \Opifer\Revisions\OpiferRevisionsBundle(),
new \Opifer\BootstrapBlockBundle\OpiferBootstrapBlockBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new \Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new \Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
} | php | public function registerBundles()
{
$bundles = [
// Symfony standard bundles
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// Added vendor bundles
new \APY\DataGridBundle\APYDataGridBundle(),
new \Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
new \Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle(),
new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new \FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\UserBundle\FOSUserBundle(),
new \JMS\SerializerBundle\JMSSerializerBundle(),
new \Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
new \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
new \Lexik\Bundle\TranslationBundle\LexikTranslationBundle(),
new \Liip\ImagineBundle\LiipImagineBundle(),
new \Limenius\LiformBundle\LimeniusLiformBundle(),
new \Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new \Nelmio\CorsBundle\NelmioCorsBundle(),
new \Scheb\TwoFactorBundle\SchebTwoFactorBundle(),
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
// Opifer bundles
new \Opifer\CmsBundle\OpiferCmsBundle(),
new \Opifer\ContentBundle\OpiferContentBundle(),
new \Opifer\EavBundle\OpiferEavBundle(),
new \Opifer\FormBundle\OpiferFormBundle(),
new \Opifer\FormBlockBundle\OpiferFormBlockBundle(),
new \Opifer\MediaBundle\OpiferMediaBundle(),
new \Opifer\RedirectBundle\OpiferRedirectBundle(),
new \Opifer\ReviewBundle\OpiferReviewBundle(),
new \Opifer\MailingListBundle\OpiferMailingListBundle(),
new \Opifer\Revisions\OpiferRevisionsBundle(),
new \Opifer\BootstrapBlockBundle\OpiferBootstrapBlockBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new \Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new \Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
} | [
"public",
"function",
"registerBundles",
"(",
")",
"{",
"$",
"bundles",
"=",
"[",
"// Symfony standard bundles",
"new",
"\\",
"Symfony",
"\\",
"Bundle",
"\\",
"FrameworkBundle",
"\\",
"FrameworkBundle",
"(",
")",
",",
"new",
"\\",
"Symfony",
"\\",
"Bundle",
"\... | Register bundles.
@return array | [
"Register",
"bundles",
"."
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/CmsKernel.php#L15-L68 | train |
Opifer/Cms | src/FormBundle/Model/FormManager.php | FormManager.createForm | public function createForm(FormInterface $form, PostInterface $post)
{
return $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]);
} | php | public function createForm(FormInterface $form, PostInterface $post)
{
return $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]);
} | [
"public",
"function",
"createForm",
"(",
"FormInterface",
"$",
"form",
",",
"PostInterface",
"$",
"post",
")",
"{",
"return",
"$",
"this",
"->",
"formFactory",
"->",
"create",
"(",
"PostType",
"::",
"class",
",",
"$",
"post",
",",
"[",
"'form_id'",
"=>",
... | Create a Symfony Form instance
@param FormInterface $form
@param PostInterface $post
@return \Symfony\Component\Form\FormInterface | [
"Create",
"a",
"Symfony",
"Form",
"instance"
] | fa288bc9d58bf9078c2fa265fa63064fa9323797 | https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Model/FormManager.php#L86-L89 | train |
gabrielqs/Magento2-Installments | Model/Config/Source/PaymentMethods.php | PaymentMethods.toOptionArray | public function toOptionArray()
{
$return = [];
$paymentMethodCodes = $this->_installmentsHelper->getAllInstallmentPaymentMethodCodes();
foreach ($paymentMethodCodes as $paymentMethodCode) {
$return[] = [
'value' => $paymentMethodCode,
'label' => ucfirst(str_replace('_', ' ', $paymentMethodCode))
];
}
return $return;
} | php | public function toOptionArray()
{
$return = [];
$paymentMethodCodes = $this->_installmentsHelper->getAllInstallmentPaymentMethodCodes();
foreach ($paymentMethodCodes as $paymentMethodCode) {
$return[] = [
'value' => $paymentMethodCode,
'label' => ucfirst(str_replace('_', ' ', $paymentMethodCode))
];
}
return $return;
} | [
"public",
"function",
"toOptionArray",
"(",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"$",
"paymentMethodCodes",
"=",
"$",
"this",
"->",
"_installmentsHelper",
"->",
"getAllInstallmentPaymentMethodCodes",
"(",
")",
";",
"foreach",
"(",
"$",
"paymentMethodCode... | Returns payment methods available for installment calculation
The methods must be declared...
@return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...) | [
"Returns",
"payment",
"methods",
"available",
"for",
"installment",
"calculation",
"The",
"methods",
"must",
"be",
"declared",
"..."
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Config/Source/PaymentMethods.php#L31-L43 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Image.php | Image.appendTiff | public function appendTiff($appendFile = "")
{
//check whether file is set or not
if ($appendFile == '')
throw new Exception('No file name specified');
$strURI = Product::$baseProductUri . '/imaging/tiff/' . $this->getFileName() . '/appendTiff?appendFile=' . $appendFile;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Status == 'OK') {
$folder = new Folder();
$outputStream = $folder->getFile($this->getFileName());
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else {
return false;
}
} | php | public function appendTiff($appendFile = "")
{
//check whether file is set or not
if ($appendFile == '')
throw new Exception('No file name specified');
$strURI = Product::$baseProductUri . '/imaging/tiff/' . $this->getFileName() . '/appendTiff?appendFile=' . $appendFile;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Status == 'OK') {
$folder = new Folder();
$outputStream = $folder->getFile($this->getFileName());
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else {
return false;
}
} | [
"public",
"function",
"appendTiff",
"(",
"$",
"appendFile",
"=",
"\"\"",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"appendFile",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'No file name specified'",
")",
";",
"$",
"strURI",
"=",
... | Appends second tiff image to the original.
@param string $appendFile The tiff image file to append.
@return string|boolean
@throws Exception | [
"Appends",
"second",
"tiff",
"image",
"to",
"the",
"original",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Image.php#L63-L86 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Image.php | Image.resizeImage | public function resizeImage($inputPath, $newWidth, $newHeight, $outputFormat)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Base file not specified');
if ($newWidth == '')
throw new Exception('New image width not specified');
if ($newHeight == '')
throw new Exception('New image height not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/resize?newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&format=' . $outputFormat;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
$outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat;
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
return $outputFilename;
} else
return $v_output;
} | php | public function resizeImage($inputPath, $newWidth, $newHeight, $outputFormat)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Base file not specified');
if ($newWidth == '')
throw new Exception('New image width not specified');
if ($newHeight == '')
throw new Exception('New image height not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/resize?newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&format=' . $outputFormat;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
$outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat;
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
return $outputFilename;
} else
return $v_output;
} | [
"public",
"function",
"resizeImage",
"(",
"$",
"inputPath",
",",
"$",
"newWidth",
",",
"$",
"newHeight",
",",
"$",
"outputFormat",
")",
"{",
"//check whether files are set or not",
"if",
"(",
"$",
"inputPath",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",... | Resize Image without Storage.
@param integer $backgroundColorIndex Index of the background color.
@param integer $pixelAspectRatio Pixel aspect ratio.
@param boolean $interlaced Specifies if image is interlaced.
@param string $outPath Name of the output file.
@return string Returns the file path.
@throws Exception | [
"Resize",
"Image",
"without",
"Storage",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Image.php#L99-L137 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Image.php | Image.cropImage | public function cropImage($x, $y, $width, $height, $outputFormat, $outPath)
{
//check whether files are set or not
if ($this->getFileName() == '')
throw new Exception('Base file not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($width == '')
throw new Exception('Width not specified');
if ($height == '')
throw new Exception('Height not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/crop?x=' . $x . '&y=' . $y . '&width=' . $width . '&height=' . $height . '&format=' . $outputFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else
return $v_output;
} | php | public function cropImage($x, $y, $width, $height, $outputFormat, $outPath)
{
//check whether files are set or not
if ($this->getFileName() == '')
throw new Exception('Base file not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($width == '')
throw new Exception('Width not specified');
if ($height == '')
throw new Exception('Height not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/crop?x=' . $x . '&y=' . $y . '&width=' . $width . '&height=' . $height . '&format=' . $outputFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else
return $v_output;
} | [
"public",
"function",
"cropImage",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"outputFormat",
",",
"$",
"outPath",
")",
"{",
"//check whether files are set or not",
"if",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")"... | Crop Image with Format Change.
@param integer $x X position of start point for cropping rectangle.
@param integer $y Y position of start point for cropping rectangle.
@param integer $width Width of cropping rectangle.
@param integer $height Height of cropping rectangle.
@param string $outPath Name of the output file.
@return string Returns the file path.
@throws Exception | [
"Crop",
"Image",
"with",
"Format",
"Change",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Image.php#L151-L196 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Image.php | Image.rotateImage | public function rotateImage($method, $outputFormat, $outPath)
{
if ($method == '')
throw new Exception('RotateFlip method not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/rotateflip?method=' . $method . '&format=' . $outputFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else
return $v_output;
} | php | public function rotateImage($method, $outputFormat, $outPath)
{
if ($method == '')
throw new Exception('RotateFlip method not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/rotateflip?method=' . $method . '&format=' . $outputFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else
return $v_output;
} | [
"public",
"function",
"rotateImage",
"(",
"$",
"method",
",",
"$",
"outputFormat",
",",
"$",
"outPath",
")",
"{",
"if",
"(",
"$",
"method",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'RotateFlip method not specified'",
")",
";",
"if",
"(",
"$",
... | RotateFlip Image on Storage.
@param string $method RotateFlip method.
@param string $outputFormat Output file format.
@param string $outPath Name of the output file.
@return string Returns the file path.
@throws Exception | [
"RotateFlip",
"Image",
"on",
"Storage",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Image.php#L208-L241 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Image.php | Image.updateImage | public function updateImage($rotateFlipMethod, $newWidth, $newHeight, $xPosition, $yPosition, $rectWidth, $rectHeight, $saveFormat, $outPath)
{
if ($rotateFlipMethod == '')
throw new Exception('Rotate Flip Method not specified');
if ($newWidth == '')
throw new Exception('New width not specified');
if ($newHeight == '')
throw new Exception('New Height not specified');
if ($xPosition == '')
throw new Exception('X position not specified');
if ($yPosition == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Rectangle width not specified');
if ($rectHeight == '')
throw new Exception('Rectangle Height not specified');
if ($saveFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/updateimage?rotateFlipMethod=' . $rotateFlipMethod .
'&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $xPosition . '&y=' . $yPosition .
'&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&format=' . $saveFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
//$json = json_decode($response);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else
return false;
} | php | public function updateImage($rotateFlipMethod, $newWidth, $newHeight, $xPosition, $yPosition, $rectWidth, $rectHeight, $saveFormat, $outPath)
{
if ($rotateFlipMethod == '')
throw new Exception('Rotate Flip Method not specified');
if ($newWidth == '')
throw new Exception('New width not specified');
if ($newHeight == '')
throw new Exception('New Height not specified');
if ($xPosition == '')
throw new Exception('X position not specified');
if ($yPosition == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Rectangle width not specified');
if ($rectHeight == '')
throw new Exception('Rectangle Height not specified');
if ($saveFormat == '')
throw new Exception('Format not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/updateimage?rotateFlipMethod=' . $rotateFlipMethod .
'&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $xPosition . '&y=' . $yPosition .
'&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&format=' . $saveFormat . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
//$json = json_decode($response);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else
return false;
} | [
"public",
"function",
"updateImage",
"(",
"$",
"rotateFlipMethod",
",",
"$",
"newWidth",
",",
"$",
"newHeight",
",",
"$",
"xPosition",
",",
"$",
"yPosition",
",",
"$",
"rectWidth",
",",
"$",
"rectHeight",
",",
"$",
"saveFormat",
",",
"$",
"outPath",
")",
... | Perform Several Operations on Image
@param string $rotateFlipMethod RotateFlip method.
@param integer $newWidth New width of the scaled image.
@param integer $newHeight New height of the scaled image.
@param integer $xPosition X position of start point for cropping rectangle.
@param integer $yPosition Y position of start point for cropping rectangle.
@param integer $rectWidth Width of cropping rectangle.
@param integer $rectHeight Height of cropping rectangle.
@param string $saveFormat Save image in another format.
@param string $outPath Path to updated file.
@return boolean|string
@throws Exception | [
"Perform",
"Several",
"Operations",
"on",
"Image"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Image.php#L259-L308 | train |
onesky/api-library-php5 | src/Onesky/Api/Client.php | Client.getActionsByResource | public function getActionsByResource($resource)
{
if (!isset($this->resources[$resource])) {
return null; // no resource found
}
$actions = array();
foreach ($this->resources[$resource] as $action => $path) {
$actions[] = $action;
}
return $actions;
} | php | public function getActionsByResource($resource)
{
if (!isset($this->resources[$resource])) {
return null; // no resource found
}
$actions = array();
foreach ($this->resources[$resource] as $action => $path) {
$actions[] = $action;
}
return $actions;
} | [
"public",
"function",
"getActionsByResource",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"resource",
"]",
")",
")",
"{",
"return",
"null",
";",
"// no resource found",
"}",
"$",
"actions",
"=",... | Retrieve actions of a resource
@param string $resource Resource name
@return array|null | [
"Retrieve",
"actions",
"of",
"a",
"resource"
] | 7baf7ea52ce4aa38b3148208e68d43d15a3ba929 | https://github.com/onesky/api-library-php5/blob/7baf7ea52ce4aa38b3148208e68d43d15a3ba929/src/Onesky/Api/Client.php#L163-L175 | train |
onesky/api-library-php5 | src/Onesky/Api/Client.php | Client.getMethodByAction | public function getMethodByAction($action)
{
foreach ($this->methods as $method => $actions) {
if (in_array($action, $actions)) {
return $method;
}
}
return 'get';
} | php | public function getMethodByAction($action)
{
foreach ($this->methods as $method => $actions) {
if (in_array($action, $actions)) {
return $method;
}
}
return 'get';
} | [
"public",
"function",
"getMethodByAction",
"(",
"$",
"action",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"methods",
"as",
"$",
"method",
"=>",
"$",
"actions",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"action",
",",
"$",
"actions",
")",
")",
"{",... | Retrieve the corresponding method to use
@param string $action Action name
@return string | [
"Retrieve",
"the",
"corresponding",
"method",
"to",
"use"
] | 7baf7ea52ce4aa38b3148208e68d43d15a3ba929 | https://github.com/onesky/api-library-php5/blob/7baf7ea52ce4aa38b3148208e68d43d15a3ba929/src/Onesky/Api/Client.php#L182-L191 | train |
onesky/api-library-php5 | src/Onesky/Api/Client.php | Client.isMultiPartAction | public function isMultiPartAction($resource, $action)
{
return isset($this->multiPartActions[$resource]) && in_array($action, $this->multiPartActions[$resource]);
} | php | public function isMultiPartAction($resource, $action)
{
return isset($this->multiPartActions[$resource]) && in_array($action, $this->multiPartActions[$resource]);
} | [
"public",
"function",
"isMultiPartAction",
"(",
"$",
"resource",
",",
"$",
"action",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"multiPartActions",
"[",
"$",
"resource",
"]",
")",
"&&",
"in_array",
"(",
"$",
"action",
",",
"$",
"this",
"->",
... | Determine if using mulit-part to upload file
@param string $resource Resource name
@param string $action Action name
@return boolean | [
"Determine",
"if",
"using",
"mulit",
"-",
"part",
"to",
"upload",
"file"
] | 7baf7ea52ce4aa38b3148208e68d43d15a3ba929 | https://github.com/onesky/api-library-php5/blob/7baf7ea52ce4aa38b3148208e68d43d15a3ba929/src/Onesky/Api/Client.php#L199-L202 | train |
onesky/api-library-php5 | src/Onesky/Api/Client.php | Client.getRequestPath | private function getRequestPath($resource, $action, &$params)
{
if (!isset($this->resources[$resource]) || !isset($this->resources[$resource][$action])) {
throw new \UnexpectedValueException('Resource path not found');
}
// get path
$path = $this->resources[$resource][$action];
// replace variables
$matchCount = preg_match_all("/:(\w*)/", $path, $variables);
if ($matchCount) {
foreach ($variables[0] as $index => $placeholder) {
if (!isset($params[$variables[1][$index]])) {
throw new \InvalidArgumentException('Missing parameter: ' . $variables[1][$index]);
}
$path = str_replace($placeholder, $params[$variables[1][$index]], $path);
unset($params[$variables[1][$index]]); // remove parameter from $params
}
}
return $path;
} | php | private function getRequestPath($resource, $action, &$params)
{
if (!isset($this->resources[$resource]) || !isset($this->resources[$resource][$action])) {
throw new \UnexpectedValueException('Resource path not found');
}
// get path
$path = $this->resources[$resource][$action];
// replace variables
$matchCount = preg_match_all("/:(\w*)/", $path, $variables);
if ($matchCount) {
foreach ($variables[0] as $index => $placeholder) {
if (!isset($params[$variables[1][$index]])) {
throw new \InvalidArgumentException('Missing parameter: ' . $variables[1][$index]);
}
$path = str_replace($placeholder, $params[$variables[1][$index]], $path);
unset($params[$variables[1][$index]]); // remove parameter from $params
}
}
return $path;
} | [
"private",
"function",
"getRequestPath",
"(",
"$",
"resource",
",",
"$",
"action",
",",
"&",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"resource",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"this"... | Retrieve request path and replace variables with values
@param string $resource Resource name
@param string $action Action name
@param array $params Parameters
@return string Request path | [
"Retrieve",
"request",
"path",
"and",
"replace",
"variables",
"with",
"values"
] | 7baf7ea52ce4aa38b3148208e68d43d15a3ba929 | https://github.com/onesky/api-library-php5/blob/7baf7ea52ce4aa38b3148208e68d43d15a3ba929/src/Onesky/Api/Client.php#L276-L299 | train |
onesky/api-library-php5 | src/Onesky/Api/Client.php | Client.callApi | private function callApi($method, $path, $params, $isMultiPart)
{
// init session
$ch = curl_init();
// request settings
curl_setopt_array($ch, $this->curlSettings); // basic settings
// url
$url = $this->endpoint . $path;
$url .= $method == 'get' ? $this->getAuthQueryStringWithParams($params) : $this->getAuthQueryString();
curl_setopt($ch, CURLOPT_URL, $url);
// http header
$requestHeaders = $this->httpHeaders;
if (!$isMultiPart) {
$requestHeaders[] = "Content-Type: application/json";
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
// method specific settings
switch ($method) {
case 'post':
curl_setopt($ch, CURLOPT_POST, 1);
// request body
if ($isMultiPart) {
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
// fallback to old method
$params['file'] = '@' . $params['file'];
} else {
// make use of CURLFile
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
$params['file'] = new \CURLFile($params['file']);
}
$postBody = $params;
} else {
$postBody = json_encode($params);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
break;
case 'put':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
case 'delete':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
}
// execute request
$response = curl_exec($ch);
// error handling
if ($response === false) {
throw new \UnexpectedValueException(curl_error($ch));
}
// close connection
curl_close($ch);
// return response
return $response;
} | php | private function callApi($method, $path, $params, $isMultiPart)
{
// init session
$ch = curl_init();
// request settings
curl_setopt_array($ch, $this->curlSettings); // basic settings
// url
$url = $this->endpoint . $path;
$url .= $method == 'get' ? $this->getAuthQueryStringWithParams($params) : $this->getAuthQueryString();
curl_setopt($ch, CURLOPT_URL, $url);
// http header
$requestHeaders = $this->httpHeaders;
if (!$isMultiPart) {
$requestHeaders[] = "Content-Type: application/json";
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
// method specific settings
switch ($method) {
case 'post':
curl_setopt($ch, CURLOPT_POST, 1);
// request body
if ($isMultiPart) {
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
// fallback to old method
$params['file'] = '@' . $params['file'];
} else {
// make use of CURLFile
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
$params['file'] = new \CURLFile($params['file']);
}
$postBody = $params;
} else {
$postBody = json_encode($params);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
break;
case 'put':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
case 'delete':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
}
// execute request
$response = curl_exec($ch);
// error handling
if ($response === false) {
throw new \UnexpectedValueException(curl_error($ch));
}
// close connection
curl_close($ch);
// return response
return $response;
} | [
"private",
"function",
"callApi",
"(",
"$",
"method",
",",
"$",
"path",
",",
"$",
"params",
",",
"$",
"isMultiPart",
")",
"{",
"// init session",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"// request settings",
"curl_setopt_array",
"(",
"$",
"ch",
",",
... | Initial request to Onesky API
@param string $method
@param string $path
@param array $params
@param boolean $isMultiPart
@return array | [
"Initial",
"request",
"to",
"Onesky",
"API"
] | 7baf7ea52ce4aa38b3148208e68d43d15a3ba929 | https://github.com/onesky/api-library-php5/blob/7baf7ea52ce4aa38b3148208e68d43d15a3ba929/src/Onesky/Api/Client.php#L316-L383 | train |
gabrielqs/Magento2-Installments | Helper/Data.php | Data.getConfigData | public function getConfigData($field, $storeId = null)
{
if (null === $storeId) {
$storeId = $this->_storeManager->getStore(null);
}
$path = 'installments/' . $field;
return $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
} | php | public function getConfigData($field, $storeId = null)
{
if (null === $storeId) {
$storeId = $this->_storeManager->getStore(null);
}
$path = 'installments/' . $field;
return $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
} | [
"public",
"function",
"getConfigData",
"(",
"$",
"field",
",",
"$",
"storeId",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"storeId",
")",
"{",
"$",
"storeId",
"=",
"$",
"this",
"->",
"_storeManager",
"->",
"getStore",
"(",
"null",
")",
";"... | Returns Cielo Payment Method System Config
@param string $field
@param null $storeId
@return array|string | [
"Returns",
"Cielo",
"Payment",
"Method",
"System",
"Config"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Helper/Data.php#L73-L80 | train |
gabrielqs/Magento2-Installments | Helper/Data.php | Data.getAllInstallmentPaymentMethodCodes | public function getAllInstallmentPaymentMethodCodes()
{
$return = [];
$paymentMethods = (array) $this->_scopeConfig->getValue('installments/payment_methods');
foreach ($paymentMethods as $code => $null) {
$return[] = $code;
}
return $return;
} | php | public function getAllInstallmentPaymentMethodCodes()
{
$return = [];
$paymentMethods = (array) $this->_scopeConfig->getValue('installments/payment_methods');
foreach ($paymentMethods as $code => $null) {
$return[] = $code;
}
return $return;
} | [
"public",
"function",
"getAllInstallmentPaymentMethodCodes",
"(",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"$",
"paymentMethods",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"_scopeConfig",
"->",
"getValue",
"(",
"'installments/payment_methods'",
")",
";",
... | Returns all installment ready payment methods' codes
@return string[] | [
"Returns",
"all",
"installment",
"ready",
"payment",
"methods",
"codes"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Helper/Data.php#L86-L94 | train |
gabrielqs/Magento2-Installments | Helper/Data.php | Data._getInstallmentsHelperFromPaymentMethod | protected function _getInstallmentsHelperFromPaymentMethod($methodCode)
{
$helperClassName = $this->_scopeConfig->getValue('installments/payment_methods/'
. $methodCode . '/installments_helper');
$helper = $this->_helperFactory->get($helperClassName);
if (false === $helper instanceof \Magento\Framework\App\Helper\AbstractHelper) {
throw new \LogicException($helperClassName .
' doesn\'t extend Magento\Framework\App\Helper\AbstractHelper');
}
return $helper;
} | php | protected function _getInstallmentsHelperFromPaymentMethod($methodCode)
{
$helperClassName = $this->_scopeConfig->getValue('installments/payment_methods/'
. $methodCode . '/installments_helper');
$helper = $this->_helperFactory->get($helperClassName);
if (false === $helper instanceof \Magento\Framework\App\Helper\AbstractHelper) {
throw new \LogicException($helperClassName .
' doesn\'t extend Magento\Framework\App\Helper\AbstractHelper');
}
return $helper;
} | [
"protected",
"function",
"_getInstallmentsHelperFromPaymentMethod",
"(",
"$",
"methodCode",
")",
"{",
"$",
"helperClassName",
"=",
"$",
"this",
"->",
"_scopeConfig",
"->",
"getValue",
"(",
"'installments/payment_methods/'",
".",
"$",
"methodCode",
".",
"'/installments_h... | Get Installments Helper from Payment Method
@param string $methodCode
@return \Magento\Framework\App\Helper\AbstractHelper
@throws \LogicException | [
"Get",
"Installments",
"Helper",
"from",
"Payment",
"Method"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Helper/Data.php#L102-L113 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Converter.php | Converter.convertLocalFile | public function convertLocalFile($inputPath, $outputFormat)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/saveAs?format=' . $outputFormat;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
$outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat;
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
return $outputFilename;
} else
return $v_output;
} | php | public function convertLocalFile($inputPath, $outputFormat)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/saveAs?format=' . $outputFormat;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
$outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat;
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
return $outputFilename;
} else
return $v_output;
} | [
"public",
"function",
"convertLocalFile",
"(",
"$",
"inputPath",
",",
"$",
"outputFormat",
")",
"{",
"//check whether files are set or not",
"if",
"(",
"$",
"inputPath",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Input file not specified'",
")",
";",
"if... | Convert Image Format.
@param string $inputPath Input file path.
@param string $outputFormat Output file format.
@return string Returns the file path.
@throws Exception | [
"Convert",
"Image",
"Format",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Converter.php#L31-L63 | train |
Speelpenning-nl/laravel-products | src/ProductsServiceProvider.php | ProductsServiceProvider.bindRepositories | protected function bindRepositories()
{
$bindings = [
AttributeRepositoryContract::class => AttributeRepository::class,
AttributeValueRepositoryContract::class => AttributeValueRepository::class,
ProductRepositoryContract::class => ProductRepository::class,
ProductTypeRepositoryContract::class => ProductTypeRepository::class,
];
foreach ($bindings as $contract => $implementation) {
$this->app->bind($contract, $implementation);
}
} | php | protected function bindRepositories()
{
$bindings = [
AttributeRepositoryContract::class => AttributeRepository::class,
AttributeValueRepositoryContract::class => AttributeValueRepository::class,
ProductRepositoryContract::class => ProductRepository::class,
ProductTypeRepositoryContract::class => ProductTypeRepository::class,
];
foreach ($bindings as $contract => $implementation) {
$this->app->bind($contract, $implementation);
}
} | [
"protected",
"function",
"bindRepositories",
"(",
")",
"{",
"$",
"bindings",
"=",
"[",
"AttributeRepositoryContract",
"::",
"class",
"=>",
"AttributeRepository",
"::",
"class",
",",
"AttributeValueRepositoryContract",
"::",
"class",
"=>",
"AttributeValueRepository",
"::... | Binds the repository abstracts to the actual implementations. | [
"Binds",
"the",
"repository",
"abstracts",
"to",
"the",
"actual",
"implementations",
"."
] | 41522ebbdd41108c1d4532bb42be602cc0c530c4 | https://github.com/Speelpenning-nl/laravel-products/blob/41522ebbdd41108c1d4532bb42be602cc0c530c4/src/ProductsServiceProvider.php#L38-L50 | train |
gabrielqs/Magento2-Installments | Model/Totals/Quote/InterestAmount.php | InterestAmount.collect | public function collect(
Quote $quote,
ShippingAssignmentInterface $shippingAssignment,
Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
$baseInterest = (float) $quote->getBaseGabrielqsInstallmentsInterestAmount();
$interest = (float) $quote->getGabrielqsInstallmentsInterestAmount();
$total->addTotalAmount('gabrielqs_installments_interest_amount', $interest);
$total->addBaseTotalAmount('gabrielqs_installments_interest_amount', $baseInterest);
$total->setBaseGrandTotal($total->getBaseGrandTotal() + $baseInterest);
$total->setGrandTotal($total->getGrandTotal() + $interest);
return $this;
} | php | public function collect(
Quote $quote,
ShippingAssignmentInterface $shippingAssignment,
Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
$baseInterest = (float) $quote->getBaseGabrielqsInstallmentsInterestAmount();
$interest = (float) $quote->getGabrielqsInstallmentsInterestAmount();
$total->addTotalAmount('gabrielqs_installments_interest_amount', $interest);
$total->addBaseTotalAmount('gabrielqs_installments_interest_amount', $baseInterest);
$total->setBaseGrandTotal($total->getBaseGrandTotal() + $baseInterest);
$total->setGrandTotal($total->getGrandTotal() + $interest);
return $this;
} | [
"public",
"function",
"collect",
"(",
"Quote",
"$",
"quote",
",",
"ShippingAssignmentInterface",
"$",
"shippingAssignment",
",",
"Total",
"$",
"total",
")",
"{",
"parent",
"::",
"collect",
"(",
"$",
"quote",
",",
"$",
"shippingAssignment",
",",
"$",
"total",
... | Collect grand total address amount
@param Quote $quote
@param ShippingAssignmentInterface $shippingAssignment
@param Total $total
@return $this | [
"Collect",
"grand",
"total",
"address",
"amount"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Totals/Quote/InterestAmount.php#L38-L55 | train |
ordermind/symfony-logical-authorization-bundle | PermissionTypes/Method/Method.php | Method.checkPermission | public function checkPermission($method, $context)
{
if (!is_string($method)) {
throw new \TypeError('The method parameter must be a string.');
}
if (!$method) {
throw new \InvalidArgumentException('The method parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return strcasecmp($currentRequest->getMethod(), $method) == 0;
} | php | public function checkPermission($method, $context)
{
if (!is_string($method)) {
throw new \TypeError('The method parameter must be a string.');
}
if (!$method) {
throw new \InvalidArgumentException('The method parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return strcasecmp($currentRequest->getMethod(), $method) == 0;
} | [
"public",
"function",
"checkPermission",
"(",
"$",
"method",
",",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"\\",
"TypeError",
"(",
"'The method parameter must be a string.'",
")",
";",
"}",
"... | Checks if the current request uses an allowed method
@param string $method The method to evaluate
@param array $context The context for evaluating the method
@return bool TRUE if the method is allowed or FALSE if it is not allowed | [
"Checks",
"if",
"the",
"current",
"request",
"uses",
"an",
"allowed",
"method"
] | 3b051f0984dcf3527024b64040bfc4b2b0855f3b | https://github.com/ordermind/symfony-logical-authorization-bundle/blob/3b051f0984dcf3527024b64040bfc4b2b0855f3b/PermissionTypes/Method/Method.php#L43-L59 | train |
ordermind/symfony-logical-authorization-bundle | PermissionTypes/Ip/Ip.php | Ip.checkPermission | public function checkPermission($ip, $context)
{
if (!is_string($ip)) {
throw new \TypeError('The ip parameter must be a string.');
}
if (!$ip) {
throw new \InvalidArgumentException('The ip parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return IpUtils::checkIp($currentRequest->getClientIp(), $ip);
} | php | public function checkPermission($ip, $context)
{
if (!is_string($ip)) {
throw new \TypeError('The ip parameter must be a string.');
}
if (!$ip) {
throw new \InvalidArgumentException('The ip parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return IpUtils::checkIp($currentRequest->getClientIp(), $ip);
} | [
"public",
"function",
"checkPermission",
"(",
"$",
"ip",
",",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"ip",
")",
")",
"{",
"throw",
"new",
"\\",
"TypeError",
"(",
"'The ip parameter must be a string.'",
")",
";",
"}",
"if",
"(",
... | Checks if the current request comes from an approved ip address
@param string $ip The ip to evaluate
@param array $context The context for evaluating the ip
@return bool TRUE if the ip is allowed or FALSE if it is not allowed | [
"Checks",
"if",
"the",
"current",
"request",
"comes",
"from",
"an",
"approved",
"ip",
"address"
] | 3b051f0984dcf3527024b64040bfc4b2b0855f3b | https://github.com/ordermind/symfony-logical-authorization-bundle/blob/3b051f0984dcf3527024b64040bfc4b2b0855f3b/PermissionTypes/Ip/Ip.php#L47-L63 | train |
gabrielqs/Magento2-Installments | Block/Sales/Order/Totals/InterestAmount.php | InterestAmount.initTotals | public function initTotals()
{
if ($value = $this->_getInterestAmount()) {
$installmentInterest = new DataObject(
[
'code' => 'gabrielqs_installments_interest_amount',
'strong' => false,
'value' => $value,
'label' => __('Interest'),
'class' => __('Interest'),
]
);
$this->getParentBlock()->addTotal($installmentInterest, 'gabrielqs_installments_interest_amount');
}
return $this;
} | php | public function initTotals()
{
if ($value = $this->_getInterestAmount()) {
$installmentInterest = new DataObject(
[
'code' => 'gabrielqs_installments_interest_amount',
'strong' => false,
'value' => $value,
'label' => __('Interest'),
'class' => __('Interest'),
]
);
$this->getParentBlock()->addTotal($installmentInterest, 'gabrielqs_installments_interest_amount');
}
return $this;
} | [
"public",
"function",
"initTotals",
"(",
")",
"{",
"if",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"_getInterestAmount",
"(",
")",
")",
"{",
"$",
"installmentInterest",
"=",
"new",
"DataObject",
"(",
"[",
"'code'",
"=>",
"'gabrielqs_installments_interest_amou... | Initialize all order totals relates with tax
@return $this | [
"Initialize",
"all",
"order",
"totals",
"relates",
"with",
"tax"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Block/Sales/Order/Totals/InterestAmount.php#L49-L66 | train |
ordermind/symfony-logical-authorization-bundle | PermissionTypes/Host/Host.php | Host.checkPermission | public function checkPermission($host, $context)
{
if (!is_string($host)) {
throw new \TypeError('The host parameter must be a string.');
}
if (!$host) {
throw new \InvalidArgumentException('The host parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return !!preg_match('{'.$host.'}i', $currentRequest->getHost());
} | php | public function checkPermission($host, $context)
{
if (!is_string($host)) {
throw new \TypeError('The host parameter must be a string.');
}
if (!$host) {
throw new \InvalidArgumentException('The host parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return !!preg_match('{'.$host.'}i', $currentRequest->getHost());
} | [
"public",
"function",
"checkPermission",
"(",
"$",
"host",
",",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"host",
")",
")",
"{",
"throw",
"new",
"\\",
"TypeError",
"(",
"'The host parameter must be a string.'",
")",
";",
"}",
"if",
... | Checks if the current request is sent to an approved host
@param string $host The host to evaluate
@param array $context The context for evaluating the host
@return bool TRUE if the host is allowed or FALSE if it is not allowed | [
"Checks",
"if",
"the",
"current",
"request",
"is",
"sent",
"to",
"an",
"approved",
"host"
] | 3b051f0984dcf3527024b64040bfc4b2b0855f3b | https://github.com/ordermind/symfony-logical-authorization-bundle/blob/3b051f0984dcf3527024b64040bfc4b2b0855f3b/PermissionTypes/Host/Host.php#L43-L59 | train |
KodiCMS/module-loader | src/ModuleContainer.php | ModuleContainer.loadConfig | public function loadConfig()
{
$path = $this->getConfigPath();
if (!is_dir($path)) {
return [];
}
$configs = Cache::remember("moduleConfig::{$path}", Carbon::now()->addMinutes(10), function () use ($path) {
$configs = [];
foreach (new \DirectoryIterator($path) as $file) {
if ($file->isDot() or strpos($file->getFilename(), '.php') === false) {
continue;
}
$key = $file->getBasename('.php');
$configs[$key] = array_merge_recursive(require $file->getPathname(), app('config')->get($key, []));
}
return $configs;
});
return $configs;
} | php | public function loadConfig()
{
$path = $this->getConfigPath();
if (!is_dir($path)) {
return [];
}
$configs = Cache::remember("moduleConfig::{$path}", Carbon::now()->addMinutes(10), function () use ($path) {
$configs = [];
foreach (new \DirectoryIterator($path) as $file) {
if ($file->isDot() or strpos($file->getFilename(), '.php') === false) {
continue;
}
$key = $file->getBasename('.php');
$configs[$key] = array_merge_recursive(require $file->getPathname(), app('config')->get($key, []));
}
return $configs;
});
return $configs;
} | [
"public",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getConfigPath",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"configs",
"=",
"Cache",
"::",
... | Register a config file namespace.
@return void | [
"Register",
"a",
"config",
"file",
"namespace",
"."
] | 733775698a1c350ea7f05e08c6fc5665bd26b6b5 | https://github.com/KodiCMS/module-loader/blob/733775698a1c350ea7f05e08c6fc5665bd26b6b5/src/ModuleContainer.php#L266-L288 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Storage/Folder.php | Folder.fileExists | public function fileExists($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIExist . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
if (!$responseStream->FileExist->IsExist) {
return FALSE;
}
return TRUE;
} | php | public function fileExists($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIExist . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
if (!$responseStream->FileExist->IsExist) {
return FALSE;
}
return TRUE;
} | [
"public",
"function",
"fileExists",
"(",
"$",
"fileName",
",",
"$",
"storageName",
"=",
"''",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"fileName",
"==",
"''",
")",
"{",
"AsposeApp",
"::",
"getLogger",
"(",
")",
"->",
"error",
"(",
"E... | Checks if a file exists.
@param string $fileName The name of file.
@param string $storageName The name of storage.
@return boolean
@throws Exception | [
"Checks",
"if",
"a",
"file",
"exists",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Storage/Folder.php#L63-L84 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Storage/Folder.php | Folder.deleteFile | public function deleteFile($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIFile . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | public function deleteFile($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIFile . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | [
"public",
"function",
"deleteFile",
"(",
"$",
"fileName",
",",
"$",
"storageName",
"=",
"''",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"fileName",
"==",
"''",
")",
"{",
"AsposeApp",
"::",
"getLogger",
"(",
")",
"->",
"error",
"(",
"E... | Deletes a file from remote storage.
@param string $fileName The name of file.
@param string $storageName The name of storage.
@return boolean
@throws Exception | [
"Deletes",
"a",
"file",
"from",
"remote",
"storage",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Storage/Folder.php#L95-L116 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Storage/Folder.php | Folder.createFolder | public function createFolder($strFolder, $storageName = '')
{
//build URI
$strURIRequest = $this->strURIFolder . $strFolder;
if ($storageName != '') {
$strURIRequest .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURIRequest);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | public function createFolder($strFolder, $storageName = '')
{
//build URI
$strURIRequest = $this->strURIFolder . $strFolder;
if ($storageName != '') {
$strURIRequest .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURIRequest);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | [
"public",
"function",
"createFolder",
"(",
"$",
"strFolder",
",",
"$",
"storageName",
"=",
"''",
")",
"{",
"//build URI",
"$",
"strURIRequest",
"=",
"$",
"this",
"->",
"strURIFolder",
".",
"$",
"strFolder",
";",
"if",
"(",
"$",
"storageName",
"!=",
"''",
... | Creates a new folder under the specified folder on Aspose storage.
If no path specified, creates a folder under the root folder.
@param string $strFolder The name of folder.
@param string $storageName The name of storage.
@return boolean | [
"Creates",
"a",
"new",
"folder",
"under",
"the",
"specified",
"folder",
"on",
"Aspose",
"storage",
".",
"If",
"no",
"path",
"specified",
"creates",
"a",
"folder",
"under",
"the",
"root",
"folder",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Storage/Folder.php#L127-L143 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Storage/Folder.php | Folder.deleteFolder | public function deleteFolder($folderName, $recursive = false)
{
//check whether folder is set or not
if ($folderName == '')
throw new Exception('No folder name specified');
//build URI
$strURI = $this->strURIFolder . $folderName;
if ($recursive) {
$strURI = $strURI . "?recursive=true";
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | public function deleteFolder($folderName, $recursive = false)
{
//check whether folder is set or not
if ($folderName == '')
throw new Exception('No folder name specified');
//build URI
$strURI = $this->strURIFolder . $folderName;
if ($recursive) {
$strURI = $strURI . "?recursive=true";
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | [
"public",
"function",
"deleteFolder",
"(",
"$",
"folderName",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"//check whether folder is set or not",
"if",
"(",
"$",
"folderName",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'No folder name specified'",
")",... | Deletes a folder from remote storage.
@param string $folderName The name of folder.
@param boolean $recursive Recursively delete the folder
@return boolean
@throws Exception | [
"Deletes",
"a",
"folder",
"from",
"remote",
"storage",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Storage/Folder.php#L154-L174 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Storage/Folder.php | Folder.getFilesList | public function getFilesList($strFolder, $storageName = '')
{
//build URI
$strURI = $this->strURIFolder;
//check whether file is set or not
if (!$strFolder == '') {
$strURI .= $strFolder;
}
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Files;
} | php | public function getFilesList($strFolder, $storageName = '')
{
//build URI
$strURI = $this->strURIFolder;
//check whether file is set or not
if (!$strFolder == '') {
$strURI .= $strFolder;
}
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Files;
} | [
"public",
"function",
"getFilesList",
"(",
"$",
"strFolder",
",",
"$",
"storageName",
"=",
"''",
")",
"{",
"//build URI",
"$",
"strURI",
"=",
"$",
"this",
"->",
"strURIFolder",
";",
"//check whether file is set or not",
"if",
"(",
"!",
"$",
"strFolder",
"==",
... | Retrives the list of files and folders under the specified folder.
Use empty string to specify root folder.
@param string $strFolder The name of folder.
@param string $storageName The name of storage.
@return array | [
"Retrives",
"the",
"list",
"of",
"files",
"and",
"folders",
"under",
"the",
"specified",
"folder",
".",
"Use",
"empty",
"string",
"to",
"specify",
"root",
"folder",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Storage/Folder.php#L237-L257 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Converter.php | Converter.convertByUrl | public function convertByUrl($url = '', $format = '', $outputFilename = '')
{
//check whether file is set or not
if ($url == '')
throw new Exception('Url not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?url=' . $url . '&format=' . $format;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($this->saveFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $this->saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . Utils::getFileName($outputFilename) . '.' . $format;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else {
return $v_output;
}
} | php | public function convertByUrl($url = '', $format = '', $outputFilename = '')
{
//check whether file is set or not
if ($url == '')
throw new Exception('Url not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?url=' . $url . '&format=' . $format;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($this->saveFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $this->saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . Utils::getFileName($outputFilename) . '.' . $format;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else {
return $v_output;
}
} | [
"public",
"function",
"convertByUrl",
"(",
"$",
"url",
"=",
"''",
",",
"$",
"format",
"=",
"''",
",",
"$",
"outputFilename",
"=",
"''",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"url",
"==",
"''",
")",
"throw",
"new",
"Exception",
"... | Convert a document by url to SaveFormat.
@param string $url URL of the document.
@param string $outputFilename The name of output file.
@return string Returns the file path.
@throws Exception | [
"Convert",
"a",
"document",
"by",
"url",
"to",
"SaveFormat",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Converter.php#L93-L120 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Converter.php | Converter.convertLocalFile | public function convertLocalFile($inputFile = '', $outputFilename = '', $outputFormat = '')
{
//check whether file is set or not
if ($inputFile == '')
throw new Exception('No file name specified');
if ($outputFormat == '')
throw new Exception('output format not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?format=' . $outputFormat;
if (!file_exists($inputFile)) {
throw new Exception('input file doesnt exist.');
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml');
$v_output = Utils::validateOutput($responseStream, $outputFormat);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
if ($outputFilename == '') {
$outputFilename = Utils::getFileName($inputFile) . '.' . $saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . $outputFilename;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | public function convertLocalFile($inputFile = '', $outputFilename = '', $outputFormat = '')
{
//check whether file is set or not
if ($inputFile == '')
throw new Exception('No file name specified');
if ($outputFormat == '')
throw new Exception('output format not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?format=' . $outputFormat;
if (!file_exists($inputFile)) {
throw new Exception('input file doesnt exist.');
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml');
$v_output = Utils::validateOutput($responseStream, $outputFormat);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
if ($outputFilename == '') {
$outputFilename = Utils::getFileName($inputFile) . '.' . $saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . $outputFilename;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"convertLocalFile",
"(",
"$",
"inputFile",
"=",
"''",
",",
"$",
"outputFilename",
"=",
"''",
",",
"$",
"outputFormat",
"=",
"''",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"inputFile",
"==",
"''",
")",
"throw",
"ne... | Convert PDF to different file format without using Aspose cloud storage.
$param string $inputFile The path of source file.
@param string $outputFilename The output file name.
@param string $outputFormat Returns document in the specified format.
@return string Returns the file path.
@throws Exception | [
"Convert",
"PDF",
"to",
"different",
"file",
"format",
"without",
"using",
"Aspose",
"cloud",
"storage",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Converter.php#L165-L203 | train |
Vovan-VE/parser | src/grammar/Rule.php | Rule.compare | public static function compare(Rule $a, Rule $b, bool $checkTag = false): int
{
return Symbol::compare($a->subject, $b->subject)
?: Symbol::compareList($a->definition, $b->definition)
?: ($b->eof - $a->eof)
?: ($checkTag ? self::compareTag($a->tag, $b->tag) : 0);
} | php | public static function compare(Rule $a, Rule $b, bool $checkTag = false): int
{
return Symbol::compare($a->subject, $b->subject)
?: Symbol::compareList($a->definition, $b->definition)
?: ($b->eof - $a->eof)
?: ($checkTag ? self::compareTag($a->tag, $b->tag) : 0);
} | [
"public",
"static",
"function",
"compare",
"(",
"Rule",
"$",
"a",
",",
"Rule",
"$",
"b",
",",
"bool",
"$",
"checkTag",
"=",
"false",
")",
":",
"int",
"{",
"return",
"Symbol",
"::",
"compare",
"(",
"$",
"a",
"->",
"subject",
",",
"$",
"b",
"->",
"... | Compare two rules
Rules are equal when its' subject symbols, definition lists and EOF marker are equal.
Equality of tags is not required by default, and is under control of `$checkTag` argument.
@param Rule $a
@param Rule $b
@param bool $checkTag [since 1.3.0] Whether to check tags too.
Default is false to ignore tags
@return int Returns 0 when rules are equal | [
"Compare",
"two",
"rules"
] | 2aaf29054129bb70167c0cc278a401ef933e87ce | https://github.com/Vovan-VE/parser/blob/2aaf29054129bb70167c0cc278a401ef933e87ce/src/grammar/Rule.php#L27-L33 | train |
ordermind/symfony-logical-authorization-bundle | PermissionTypes/Flag/Flags/UserCanBypassAccess.php | UserCanBypassAccess.checkFlag | public function checkFlag(array $context): bool
{
if (!isset($context['user'])) {
throw new \InvalidArgumentException(sprintf('The context parameter must contain a "user" key to be able to evaluate the %s flag.', $this->getName()));
}
$user = $context['user'];
if (is_string($user)) { //Anonymous user
return false;
}
if (!($user instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
$access = $user->getBypassAccess();
if (!is_bool($access)) {
throw new \UnexpectedValueException(sprintf('The method getBypassAccess() on the user object must return a boolean. Returned type is %s.', gettype($access)));
}
return $access;
} | php | public function checkFlag(array $context): bool
{
if (!isset($context['user'])) {
throw new \InvalidArgumentException(sprintf('The context parameter must contain a "user" key to be able to evaluate the %s flag.', $this->getName()));
}
$user = $context['user'];
if (is_string($user)) { //Anonymous user
return false;
}
if (!($user instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
$access = $user->getBypassAccess();
if (!is_bool($access)) {
throw new \UnexpectedValueException(sprintf('The method getBypassAccess() on the user object must return a boolean. Returned type is %s.', gettype($access)));
}
return $access;
} | [
"public",
"function",
"checkFlag",
"(",
"array",
"$",
"context",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"context",
"[",
"'user'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The context ... | Checks if access can be bypassed in a given context.
@param array $context The context for evaluating the flag. The context must contain a 'user' key which references either a user string (to signify an anonymous user) or an object implementing Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface. You can get the current user by calling getCurrentUser() from the service 'logauth.service.helper'.
@return bool TRUE if access can be bypassed or FALSE if access can't be bypassed. | [
"Checks",
"if",
"access",
"can",
"be",
"bypassed",
"in",
"a",
"given",
"context",
"."
] | 3b051f0984dcf3527024b64040bfc4b2b0855f3b | https://github.com/ordermind/symfony-logical-authorization-bundle/blob/3b051f0984dcf3527024b64040bfc4b2b0855f3b/PermissionTypes/Flag/Flags/UserCanBypassAccess.php#L30-L50 | train |
gabrielqs/Magento2-Installments | Block/MaximumInstallments/Cart.php | Cart.getMaximumInstallment | public function getMaximumInstallment()
{
if ($this->_maximumInstallment === null) {
$grandTotal = $this->getCartGrandTotal();
$this->_maximumInstallment = $this->_installmentsHelper->getMaximumInstallment($grandTotal);
}
return $this->_maximumInstallment;
} | php | public function getMaximumInstallment()
{
if ($this->_maximumInstallment === null) {
$grandTotal = $this->getCartGrandTotal();
$this->_maximumInstallment = $this->_installmentsHelper->getMaximumInstallment($grandTotal);
}
return $this->_maximumInstallment;
} | [
"public",
"function",
"getMaximumInstallment",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_maximumInstallment",
"===",
"null",
")",
"{",
"$",
"grandTotal",
"=",
"$",
"this",
"->",
"getCartGrandTotal",
"(",
")",
";",
"$",
"this",
"->",
"_maximumInstallment... | Returns maximum instalment for the currently active shopping cart
@return DataObject | [
"Returns",
"maximum",
"instalment",
"for",
"the",
"currently",
"active",
"shopping",
"cart"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Block/MaximumInstallments/Cart.php#L84-L91 | train |
EvilFreelancer/openvpn-php | src/Import.php | Import.read | public function read(string $filename): array
{
$lines = ['total' => 0, 'read' => 0];
// Open file as SPL object
$file = new \SplFileObject($filename);
// Read line by line
while (!$file->eof()) {
$line = $file->fgets();
// Save line only of not empty
if ($this->isLine($line) && \strlen($line) > 1) {
$line = trim(preg_replace('/\s+/', ' ', $line));
$this->_lines[] = $line;
$lines['read']++;
}
$lines['total']++;
}
return $lines;
} | php | public function read(string $filename): array
{
$lines = ['total' => 0, 'read' => 0];
// Open file as SPL object
$file = new \SplFileObject($filename);
// Read line by line
while (!$file->eof()) {
$line = $file->fgets();
// Save line only of not empty
if ($this->isLine($line) && \strlen($line) > 1) {
$line = trim(preg_replace('/\s+/', ' ', $line));
$this->_lines[] = $line;
$lines['read']++;
}
$lines['total']++;
}
return $lines;
} | [
"public",
"function",
"read",
"(",
"string",
"$",
"filename",
")",
":",
"array",
"{",
"$",
"lines",
"=",
"[",
"'total'",
"=>",
"0",
",",
"'read'",
"=>",
"0",
"]",
";",
"// Open file as SPL object",
"$",
"file",
"=",
"new",
"\\",
"SplFileObject",
"(",
"... | Read configuration file line by line
@param string $filename
@return array Array with count of total and read lines | [
"Read",
"configuration",
"file",
"line",
"by",
"line"
] | 29cdc6566d1c97e16ed158e97d34a8bd03045d9a | https://github.com/EvilFreelancer/openvpn-php/blob/29cdc6566d1c97e16ed158e97d34a8bd03045d9a/src/Import.php#L49-L68 | train |
EvilFreelancer/openvpn-php | src/Import.php | Import.parse | public function parse(): ConfigInterface
{
$config = new Config();
array_map(
function($line) use ($config) {
if (preg_match('/^(\S+)\ (.*)/', $line, $matches)) {
switch ($matches[1]) {
case 'push':
$config->addPush($matches[2]);
break;
case 'ca':
case 'cert':
case 'key':
case 'dh':
case 'tls-auth':
$config->addCert($matches[1], $matches[2]);
break;
default:
$config->add($matches[1], $matches[2]);
break;
}
}
},
$this->_lines
);
return $config;
} | php | public function parse(): ConfigInterface
{
$config = new Config();
array_map(
function($line) use ($config) {
if (preg_match('/^(\S+)\ (.*)/', $line, $matches)) {
switch ($matches[1]) {
case 'push':
$config->addPush($matches[2]);
break;
case 'ca':
case 'cert':
case 'key':
case 'dh':
case 'tls-auth':
$config->addCert($matches[1], $matches[2]);
break;
default:
$config->add($matches[1], $matches[2]);
break;
}
}
},
$this->_lines
);
return $config;
} | [
"public",
"function",
"parse",
"(",
")",
":",
"ConfigInterface",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"array_map",
"(",
"function",
"(",
"$",
"line",
")",
"use",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(\\S... | Parse readed lines
@return ConfigInterface | [
"Parse",
"readed",
"lines"
] | 29cdc6566d1c97e16ed158e97d34a8bd03045d9a | https://github.com/EvilFreelancer/openvpn-php/blob/29cdc6566d1c97e16ed158e97d34a8bd03045d9a/src/Import.php#L75-L101 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.getPageCount | public function getPageCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Pages->List);
} | php | public function getPageCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Pages->List);
} | [
"public",
"function",
"getPageCount",
"(",
")",
"{",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/pdf/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/pages'",
";",
"//sign URI",
"$",
"signedURI",
"=",
"Uti... | Gets the page count of the specified PDF document.
@return integer | [
"Gets",
"the",
"page",
"count",
"of",
"the",
"specified",
"PDF",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L29-L43 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.appendDocument | public function appendDocument($basePdf, $newPdf, $startPage = 0, $endPage = 0, $sourceFolder = '')
{
//check whether files are set or not
if ($basePdf == '')
throw new Exception('Base file not specified');
if ($newPdf == '')
throw new Exception('File to merge is not specified');
//build URI to merge PDFs
if ($sourceFolder == '')
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $newPdf . ($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '');
else
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $sourceFolder . '/' . $newPdf .
($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '') .
'&folder=' . $sourceFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
$folder = new Folder();
$path = "";
if ($sourceFolder == "") {
$path = $basePdf;
} else {
$path = $sourceFolder . '/' . $basePdf;
}
$outputStream = $folder->GetFile($path);
$outputPath = AsposeApp::$outPutLocation . $basePdf;
Utils::saveFile($outputStream, $outputPath);
} else {
return false;
}
} | php | public function appendDocument($basePdf, $newPdf, $startPage = 0, $endPage = 0, $sourceFolder = '')
{
//check whether files are set or not
if ($basePdf == '')
throw new Exception('Base file not specified');
if ($newPdf == '')
throw new Exception('File to merge is not specified');
//build URI to merge PDFs
if ($sourceFolder == '')
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $newPdf . ($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '');
else
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $sourceFolder . '/' . $newPdf .
($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '') .
'&folder=' . $sourceFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
$folder = new Folder();
$path = "";
if ($sourceFolder == "") {
$path = $basePdf;
} else {
$path = $sourceFolder . '/' . $basePdf;
}
$outputStream = $folder->GetFile($path);
$outputPath = AsposeApp::$outPutLocation . $basePdf;
Utils::saveFile($outputStream, $outputPath);
} else {
return false;
}
} | [
"public",
"function",
"appendDocument",
"(",
"$",
"basePdf",
",",
"$",
"newPdf",
",",
"$",
"startPage",
"=",
"0",
",",
"$",
"endPage",
"=",
"0",
",",
"$",
"sourceFolder",
"=",
"''",
")",
"{",
"//check whether files are set or not",
"if",
"(",
"$",
"basePdf... | Merges two PDF documents.
@param string $basePdf (name of the base/first PDF file)
@param string $newPdf (name of the second PDF file to merge with base PDF file)
@param string $startPage (page number to start merging second PDF: enter 0 to merge complete document)
@param string $endPage (page number to end merging second PDF: enter 0 to merge complete document)
@param string $sourceFolder (name of the folder where base/first and second input PDFs are present)
@return string|boolean
@throws Exception | [
"Merges",
"two",
"PDF",
"documents",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L57-L98 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.mergeDocuments | public function mergeDocuments(array $sourceFiles = array())
{
$mergedFileName = $this->getFileName();
//check whether files are set or not
if ($mergedFileName == '')
throw new Exception('Output file not specified');
if (empty($sourceFiles))
throw new Exception('File to merge are not specified');
if (count($sourceFiles) < 2)
throw new Exception('Two or more files are requred to merge');
//Build JSON to post
$documentsList = array('List' => $sourceFiles);
$json = json_encode($documentsList);
$strURI = Product::$baseProductUri . '/pdf/' . $mergedFileName . '/merge';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', 'json', $json));
if ($responseStream->Code == 200)
return true;
else
return false;
} | php | public function mergeDocuments(array $sourceFiles = array())
{
$mergedFileName = $this->getFileName();
//check whether files are set or not
if ($mergedFileName == '')
throw new Exception('Output file not specified');
if (empty($sourceFiles))
throw new Exception('File to merge are not specified');
if (count($sourceFiles) < 2)
throw new Exception('Two or more files are requred to merge');
//Build JSON to post
$documentsList = array('List' => $sourceFiles);
$json = json_encode($documentsList);
$strURI = Product::$baseProductUri . '/pdf/' . $mergedFileName . '/merge';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', 'json', $json));
if ($responseStream->Code == 200)
return true;
else
return false;
} | [
"public",
"function",
"mergeDocuments",
"(",
"array",
"$",
"sourceFiles",
"=",
"array",
"(",
")",
")",
"{",
"$",
"mergedFileName",
"=",
"$",
"this",
"->",
"getFileName",
"(",
")",
";",
"//check whether files are set or not",
"if",
"(",
"$",
"mergedFileName",
"... | Merges tow or more PDF documents.
@param array $sourceFiles List of PDF files to be merged
@return boolean
@throws Exception | [
"Merges",
"tow",
"or",
"more",
"PDF",
"documents",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L108-L135 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.getFormFieldCount | public function getFormFieldCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Fields->List);
} | php | public function getFormFieldCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Fields->List);
} | [
"public",
"function",
"getFormFieldCount",
"(",
")",
"{",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/pdf/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/fields'",
";",
"//sign URI",
"$",
"signedURI",
"=",
... | Gets the FormField count of the specified PDF document.
@return integer | [
"Gets",
"the",
"FormField",
"count",
"of",
"the",
"specified",
"PDF",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L340-L354 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.getFormField | public function getFormField($fieldName)
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return $json->Field;
} | php | public function getFormField($fieldName)
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return $json->Field;
} | [
"public",
"function",
"getFormField",
"(",
"$",
"fieldName",
")",
"{",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/pdf/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/fields/'",
".",
"$",
"fieldName",
";"... | Gets a particular form field.
@param string $fieldName Name of the field.
@return object | [
"Gets",
"a",
"particular",
"form",
"field",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L384-L398 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.updateFormFields | public function updateFormFields(array $fieldArray, $documentFolder = '')
{
if (count($fieldArray) === 0)
throw new Exception('Field array cannot be empty');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields?folder=' . $documentFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
'List' => $fieldArray
));
//get response stream
$responseStream = Utils::processCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save docs on server
$folder = new Folder();
if ($documentFolder) {
$outputStream = $folder->getFile($documentFolder . '/' . $this->getFileName());
} else {
$outputStream = $folder->getFile($this->getFileName());
}
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | public function updateFormFields(array $fieldArray, $documentFolder = '')
{
if (count($fieldArray) === 0)
throw new Exception('Field array cannot be empty');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields?folder=' . $documentFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
'List' => $fieldArray
));
//get response stream
$responseStream = Utils::processCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save docs on server
$folder = new Folder();
if ($documentFolder) {
$outputStream = $folder->getFile($documentFolder . '/' . $this->getFileName());
} else {
$outputStream = $folder->getFile($this->getFileName());
}
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"updateFormFields",
"(",
"array",
"$",
"fieldArray",
",",
"$",
"documentFolder",
"=",
"''",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"fieldArray",
")",
"===",
"0",
")",
"throw",
"new",
"Exception",
"(",
"'Field array cannot be empty'",
"... | Update Form Fields in a PDF Document.
@param array $fieldArray Fields in an array
@param string $documentFolder Where the template resides
@return bool
@throws Exception | [
"Update",
"Form",
"Fields",
"in",
"a",
"PDF",
"Document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L409-L445 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.updateFormField | public function updateFormField($fieldName, $fieldType, $fieldValue)
{
if ($fieldName == '')
throw new Exception('Field name not specified');
if ($fieldType == '')
throw new Exception('Field type not specified');
if ($fieldValue == '')
throw new Exception('Field value not specified');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
"Name" => $fieldName,
"Type" => $fieldType,
"Values" => array($fieldValue)
));
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Field;
else
return false;
} | php | public function updateFormField($fieldName, $fieldType, $fieldValue)
{
if ($fieldName == '')
throw new Exception('Field name not specified');
if ($fieldType == '')
throw new Exception('Field type not specified');
if ($fieldValue == '')
throw new Exception('Field value not specified');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
"Name" => $fieldName,
"Type" => $fieldType,
"Values" => array($fieldValue)
));
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Field;
else
return false;
} | [
"public",
"function",
"updateFormField",
"(",
"$",
"fieldName",
",",
"$",
"fieldType",
",",
"$",
"fieldValue",
")",
"{",
"if",
"(",
"$",
"fieldName",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Field name not specified'",
")",
";",
"if",
"(",
"$",... | Update a Form Field in a PDF Document.
@param string $fieldName The name of the field.
@param string $fieldType A value indicating the type of the form field. Available values - text, boolean, integer, list.
@param string $fieldValue The value of the form field.
@return object|boolean
@throws Exception | [
"Update",
"a",
"Form",
"Field",
"in",
"a",
"PDF",
"Document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L457-L489 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.getDocumentProperties | public function getDocumentProperties()
{
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperties->List;
} | php | public function getDocumentProperties()
{
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperties->List;
} | [
"public",
"function",
"getDocumentProperties",
"(",
")",
"{",
"//build URI to replace image",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/pdf/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/documentProperties'",
";",
"//sign UR... | Get all the properties of the specified document .
@return array
@throws Exception | [
"Get",
"all",
"the",
"properties",
"of",
"the",
"specified",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L696-L709 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.getDocumentProperty | public function getDocumentProperty($propertyName = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | php | public function getDocumentProperty($propertyName = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | [
"public",
"function",
"getDocumentProperty",
"(",
"$",
"propertyName",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"propertyName",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Property name not specified'",
")",
";",
"//build URI to replace image",
"$",
"strURI",... | Get specified properity of the document.
@param string $propertyName Name of the property.
@return object
@throws Exception | [
"Get",
"specified",
"properity",
"of",
"the",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L719-L735 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.setDocumentProperty | public function setDocumentProperty($propertyName = '', $propertyValue = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
$putArray['Value'] = $propertyValue;
$json = json_encode($putArray);
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $json);
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | php | public function setDocumentProperty($propertyName = '', $propertyValue = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
$putArray['Value'] = $propertyValue;
$json = json_encode($putArray);
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $json);
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | [
"public",
"function",
"setDocumentProperty",
"(",
"$",
"propertyName",
"=",
"''",
",",
"$",
"propertyValue",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"propertyName",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Property name not specified'",
")",
";",
"/... | Set specified properity of the document.
@param string $propertyName Name of the property.
@param string $propertyValue Value of the property.
@return object
@throws Exception | [
"Set",
"specified",
"properity",
"of",
"the",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L746-L765 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Pdf/Document.php | Document.splitPages | public function splitPages($from, $to)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/split?from=' . $from . '&to=' . $to;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
$dispatcher = AsposeApp::getEventDispatcher();
$pageNumber = 1;
foreach ($json->Result->Documents as $splitPage) {
$splitFileName = basename($splitPage->Href);
$strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$fileName = $this->getFileName() . '_' . $pageNumber . '.pdf';
$outputFile = AsposeApp::$outPutLocation . $fileName;
Utils::saveFile($responseStream, $outputFile);
echo $outputFile . '<br />';
$event = new SplitPageEvent($outputFile, $pageNumber);
$dispatcher->dispatch(SplitPageEvent::PAGE_IS_SPLIT, $event);
$pageNumber++;
}
} | php | public function splitPages($from, $to)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/split?from=' . $from . '&to=' . $to;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
$dispatcher = AsposeApp::getEventDispatcher();
$pageNumber = 1;
foreach ($json->Result->Documents as $splitPage) {
$splitFileName = basename($splitPage->Href);
$strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$fileName = $this->getFileName() . '_' . $pageNumber . '.pdf';
$outputFile = AsposeApp::$outPutLocation . $fileName;
Utils::saveFile($responseStream, $outputFile);
echo $outputFile . '<br />';
$event = new SplitPageEvent($outputFile, $pageNumber);
$dispatcher->dispatch(SplitPageEvent::PAGE_IS_SPLIT, $event);
$pageNumber++;
}
} | [
"public",
"function",
"splitPages",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/pdf/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/split?from='",
".",
"$",
"from",
".",
... | Split page into documents as specified in the range.
@param integer $from From page number.
@param integer $to To page number.
@return string Returns the file path.
@throws Exception | [
"Split",
"page",
"into",
"documents",
"as",
"specified",
"in",
"the",
"range",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Pdf/Document.php#L831-L859 | train |
ElfSundae/bearychat | src/Message.php | Message.setClient | public function setClient($client)
{
if ($client instanceof Client && $this->client != $client) {
$this->configureDefaults($client->getMessageDefaults(), true);
}
$this->client = $client;
return $this;
} | php | public function setClient($client)
{
if ($client instanceof Client && $this->client != $client) {
$this->configureDefaults($client->getMessageDefaults(), true);
}
$this->client = $client;
return $this;
} | [
"public",
"function",
"setClient",
"(",
"$",
"client",
")",
"{",
"if",
"(",
"$",
"client",
"instanceof",
"Client",
"&&",
"$",
"this",
"->",
"client",
"!=",
"$",
"client",
")",
"{",
"$",
"this",
"->",
"configureDefaults",
"(",
"$",
"client",
"->",
"getM... | Set the BearyChat Client instance.
@param \ElfSundae\BearyChat\Client|null $client
@return $this | [
"Set",
"the",
"BearyChat",
"Client",
"instance",
"."
] | b696c88deae1c90f679edf53ff0760602edba701 | https://github.com/ElfSundae/bearychat/blob/b696c88deae1c90f679edf53ff0760602edba701/src/Message.php#L91-L100 | train |
ElfSundae/bearychat | src/Message.php | Message.setChannel | public function setChannel($channel)
{
$this->removeTarget();
if ($channel) {
$this->channel = (string) $channel;
}
return $this;
} | php | public function setChannel($channel)
{
$this->removeTarget();
if ($channel) {
$this->channel = (string) $channel;
}
return $this;
} | [
"public",
"function",
"setChannel",
"(",
"$",
"channel",
")",
"{",
"$",
"this",
"->",
"removeTarget",
"(",
")",
";",
"if",
"(",
"$",
"channel",
")",
"{",
"$",
"this",
"->",
"channel",
"=",
"(",
"string",
")",
"$",
"channel",
";",
"}",
"return",
"$"... | Set the channel which the message should be sent to.
@param string $channel
@return $this | [
"Set",
"the",
"channel",
"which",
"the",
"message",
"should",
"be",
"sent",
"to",
"."
] | b696c88deae1c90f679edf53ff0760602edba701 | https://github.com/ElfSundae/bearychat/blob/b696c88deae1c90f679edf53ff0760602edba701/src/Message.php#L220-L229 | train |
ElfSundae/bearychat | src/Message.php | Message.setUser | public function setUser($user)
{
$this->removeTarget();
if ($user) {
$this->user = (string) $user;
}
return $this;
} | php | public function setUser($user)
{
$this->removeTarget();
if ($user) {
$this->user = (string) $user;
}
return $this;
} | [
"public",
"function",
"setUser",
"(",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"removeTarget",
"(",
")",
";",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"(",
"string",
")",
"$",
"user",
";",
"}",
"return",
"$",
"this",
"... | Set the user which the message should be sent to.
@param string $user
@return $this | [
"Set",
"the",
"user",
"which",
"the",
"message",
"should",
"be",
"sent",
"to",
"."
] | b696c88deae1c90f679edf53ff0760602edba701 | https://github.com/ElfSundae/bearychat/blob/b696c88deae1c90f679edf53ff0760602edba701/src/Message.php#L258-L267 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.