repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchTv | public function searchTv($query, TvSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchTv($query, $this->getParameters($parameters), $headers);
return $this->getTvFactory()->createResultCollection($data);
} | php | public function searchTv($query, TvSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchTv($query, $this->getParameters($parameters), $headers);
return $this->getTvFactory()->createResultCollection($data);
} | [
"public",
"function",
"searchTv",
"(",
"$",
"query",
",",
"TvSearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchTv",
"(",
"$",
"query",
",",
... | @param string $query
@param TvSearchQuery $parameters
@param array $headers
@return ResultCollection|Tv[] | [
"@param",
"string",
"$query",
"@param",
"TvSearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L129-L134 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchPerson | public function searchPerson($query, PersonSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchPersons($query, $this->getParameters($parameters), $headers);
return $this->getPeopleFactory()->createResultCollection($data);
} | php | public function searchPerson($query, PersonSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchPersons($query, $this->getParameters($parameters), $headers);
return $this->getPeopleFactory()->createResultCollection($data);
} | [
"public",
"function",
"searchPerson",
"(",
"$",
"query",
",",
"PersonSearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchPersons",
"(",
"$",
"quer... | @param string $query
@param PersonSearchQuery $parameters
@param array $headers
@return ResultCollection|Person[] | [
"@param",
"string",
"$query",
"@param",
"PersonSearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L143-L148 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchList | public function searchList($query, ListSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchList($query, $this->getParameters($parameters), $headers);
return $this->getListitemFactory()->createResultCollection($data);
} | php | public function searchList($query, ListSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchList($query, $this->getParameters($parameters), $headers);
return $this->getListitemFactory()->createResultCollection($data);
} | [
"public",
"function",
"searchList",
"(",
"$",
"query",
",",
"ListSearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchList",
"(",
"$",
"query",
"... | @param string $query
@param ListSearchQuery $parameters
@param array $headers
@return ResultCollection | [
"@param",
"string",
"$query",
"@param",
"ListSearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L157-L162 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchCompany | public function searchCompany($query, CompanySearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchCompany($query, $this->getParameters($parameters), $headers);
return $this->getCompanyFactory()->createResultCollection($data);
} | php | public function searchCompany($query, CompanySearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchCompany($query, $this->getParameters($parameters), $headers);
return $this->getCompanyFactory()->createResultCollection($data);
} | [
"public",
"function",
"searchCompany",
"(",
"$",
"query",
",",
"CompanySearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchCompany",
"(",
"$",
"qu... | @param string $query
@param CompanySearchQuery $parameters
@param array $headers
@return ResultCollection|Company[] | [
"@param",
"string",
"$query",
"@param",
"CompanySearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L171-L176 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchKeyword | public function searchKeyword($query, KeywordSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchKeyword($query, $this->getParameters($parameters), $headers);
return $this->getKeywordFactory()->createResultCollection($data);
} | php | public function searchKeyword($query, KeywordSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchKeyword($query, $this->getParameters($parameters), $headers);
return $this->getKeywordFactory()->createResultCollection($data);
} | [
"public",
"function",
"searchKeyword",
"(",
"$",
"query",
",",
"KeywordSearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchKeyword",
"(",
"$",
"qu... | @param string $query
@param KeywordSearchQuery $parameters
@param array $headers
@return ResultCollection|Keyword[] | [
"@param",
"string",
"$query",
"@param",
"KeywordSearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L185-L190 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.searchMulti | public function searchMulti($query, KeywordSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchMulti($query, $this->getParameters($parameters), $headers);
$collection = new ResultCollection();
if (null === $data) {
return $collection;
}
if (array_key_exists('page', $data)) {
$collection->setPage($data['page']);
}
if (array_key_exists('total_pages', $data)) {
$collection->setTotalPages($data['total_pages']);
}
if (array_key_exists('total_results', $data)) {
$collection->setTotalResults($data['total_results']);
}
if (array_key_exists('results', $data)) {
foreach ($data['results'] as $item) {
if ($item) {
$collection->add(null, $this->processSearchMultiItem($item));
}
}
}
return $collection;
} | php | public function searchMulti($query, KeywordSearchQuery $parameters, array $headers = [])
{
$data = $this->getApi()->searchMulti($query, $this->getParameters($parameters), $headers);
$collection = new ResultCollection();
if (null === $data) {
return $collection;
}
if (array_key_exists('page', $data)) {
$collection->setPage($data['page']);
}
if (array_key_exists('total_pages', $data)) {
$collection->setTotalPages($data['total_pages']);
}
if (array_key_exists('total_results', $data)) {
$collection->setTotalResults($data['total_results']);
}
if (array_key_exists('results', $data)) {
foreach ($data['results'] as $item) {
if ($item) {
$collection->add(null, $this->processSearchMultiItem($item));
}
}
}
return $collection;
} | [
"public",
"function",
"searchMulti",
"(",
"$",
"query",
",",
"KeywordSearchQuery",
"$",
"parameters",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getApi",
"(",
")",
"->",
"searchMulti",
"(",
"$",
"query"... | @param string $query
@param KeywordSearchQuery $parameters
@param array $headers
@return ResultCollection|Keyword[] | [
"@param",
"string",
"$query",
"@param",
"KeywordSearchQuery",
"$parameters",
"@param",
"array",
"$headers"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L199-L229 |
php-tmdb/api | lib/Tmdb/Repository/SearchRepository.php | SearchRepository.processSearchMultiItem | private function processSearchMultiItem(array $item)
{
if (array_key_exists('media_type', $item)) {
switch ($item['media_type']) {
case 'movie':
return $this->getMovieFactory()->create($item);
case 'tv':
return $this->getTvFactory()->create($item);
case 'person':
return $this->getPeopleFactory()->create($item);
default:
throw new \RuntimeException(sprintf(
'Could not process media_type "%s" in multi search, type unknown.',
$item['media_type']
));
}
}
return false;
} | php | private function processSearchMultiItem(array $item)
{
if (array_key_exists('media_type', $item)) {
switch ($item['media_type']) {
case 'movie':
return $this->getMovieFactory()->create($item);
case 'tv':
return $this->getTvFactory()->create($item);
case 'person':
return $this->getPeopleFactory()->create($item);
default:
throw new \RuntimeException(sprintf(
'Could not process media_type "%s" in multi search, type unknown.',
$item['media_type']
));
}
}
return false;
} | [
"private",
"function",
"processSearchMultiItem",
"(",
"array",
"$",
"item",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'media_type'",
",",
"$",
"item",
")",
")",
"{",
"switch",
"(",
"$",
"item",
"[",
"'media_type'",
"]",
")",
"{",
"case",
"'movie'",
... | Process multi search items
@param array $item
@return bool|Movie|Person|Person\CastMember|Person\CrewMember|Tv
@throws \RuntimeException | [
"Process",
"multi",
"search",
"items"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Repository/SearchRepository.php#L238-L257 |
php-tmdb/api | lib/Tmdb/Model/Collection/Genres.php | Genres.getGenre | public function getGenre($id)
{
foreach ($this->data as $genre) {
if ($id === $genre->getId()) {
return $genre;
}
}
return null;
} | php | public function getGenre($id)
{
foreach ($this->data as $genre) {
if ($id === $genre->getId()) {
return $genre;
}
}
return null;
} | [
"public",
"function",
"getGenre",
"(",
"$",
"id",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"genre",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"$",
"genre",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"genre",
";",
"}",... | Retrieve a genre from the collection
@param $id
@return Genre|null | [
"Retrieve",
"a",
"genre",
"from",
"the",
"collection"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Model/Collection/Genres.php#L40-L49 |
php-tmdb/api | lib/Tmdb/Factory/FindFactory.php | FindFactory.create | public function create(array $data = [])
{
$find = new Find();
if (array_key_exists('movie_results', $data)) {
$find->setMovieResults($this->getMovieFactory()->createCollection($data['movie_results']));
}
if (array_key_exists('person_results', $data)) {
$find->setPersonResults($this->getPeopleFactory()->createCollection($data['person_results']));
}
if (array_key_exists('tv_results', $data)) {
$find->setTvResults($this->getTvFactory()->createCollection($data['tv_results']));
}
if (array_key_exists('tv_season_results', $data)) {
$find->setTvSeasonResults($this->getTvSeasonFactory()->createCollection($data['tv_season_results']));
}
if (array_key_exists('tv_episode_results', $data)) {
$find->setTvEpisodeResults($this->getTvSeasonFactory()->createCollection($data['tv_episode_results']));
}
return $find;
} | php | public function create(array $data = [])
{
$find = new Find();
if (array_key_exists('movie_results', $data)) {
$find->setMovieResults($this->getMovieFactory()->createCollection($data['movie_results']));
}
if (array_key_exists('person_results', $data)) {
$find->setPersonResults($this->getPeopleFactory()->createCollection($data['person_results']));
}
if (array_key_exists('tv_results', $data)) {
$find->setTvResults($this->getTvFactory()->createCollection($data['tv_results']));
}
if (array_key_exists('tv_season_results', $data)) {
$find->setTvSeasonResults($this->getTvSeasonFactory()->createCollection($data['tv_season_results']));
}
if (array_key_exists('tv_episode_results', $data)) {
$find->setTvEpisodeResults($this->getTvSeasonFactory()->createCollection($data['tv_episode_results']));
}
return $find;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"find",
"=",
"new",
"Find",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'movie_results'",
",",
"$",
"data",
")",
")",
"{",
"$",
"find",
"->",
"setMovie... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Factory/FindFactory.php#L68-L93 |
php-tmdb/api | lib/Tmdb/Factory/Lists/ListItemFactory.php | ListItemFactory.create | public function create(array $data = [])
{
$listItem = new ListItem();
/** Images */
if (array_key_exists('backdrop_path', $data)) {
$listItem->setBackdropImage(
$this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
);
}
if (array_key_exists('poster_path', $data)) {
$listItem->setPosterImage(
$this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
);
}
return $this->hydrate($listItem, $data);
} | php | public function create(array $data = [])
{
$listItem = new ListItem();
/** Images */
if (array_key_exists('backdrop_path', $data)) {
$listItem->setBackdropImage(
$this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
);
}
if (array_key_exists('poster_path', $data)) {
$listItem->setPosterImage(
$this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
);
}
return $this->hydrate($listItem, $data);
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"listItem",
"=",
"new",
"ListItem",
"(",
")",
";",
"/** Images */",
"if",
"(",
"array_key_exists",
"(",
"'backdrop_path'",
",",
"$",
"data",
")",
")",
"{",
"$",
... | @param array $data
@return ListItem | [
"@param",
"array",
"$data"
] | train | https://github.com/php-tmdb/api/blob/92cbf43a291bf0113ff2cce91d2db242fe6e6fcb/lib/Tmdb/Factory/Lists/ListItemFactory.php#L49-L67 |
dmishh/SettingsBundle | Controller/SettingsController.php | SettingsController.manageGlobalAction | public function manageGlobalAction(Request $request)
{
$securitySettings = $this->container->getParameter('settings_manager.security');
if (!empty($securitySettings['manage_global_settings_role']) &&
!$this->getAuthorizationChecker()->isGranted($securitySettings['manage_global_settings_role'])
) {
throw new AccessDeniedException(
$this->container->get('translator')->trans(
'not_allowed_to_edit_global_settings',
array(),
'settings'
)
);
}
return $this->manage($request);
} | php | public function manageGlobalAction(Request $request)
{
$securitySettings = $this->container->getParameter('settings_manager.security');
if (!empty($securitySettings['manage_global_settings_role']) &&
!$this->getAuthorizationChecker()->isGranted($securitySettings['manage_global_settings_role'])
) {
throw new AccessDeniedException(
$this->container->get('translator')->trans(
'not_allowed_to_edit_global_settings',
array(),
'settings'
)
);
}
return $this->manage($request);
} | [
"public",
"function",
"manageGlobalAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"securitySettings",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'settings_manager.security'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"security... | @param Request $request
@return \Symfony\Component\HttpFoundation\Response
@throws \Symfony\Component\Security\Core\Exception\AccessDeniedException | [
"@param",
"Request",
"$request"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Controller/SettingsController.php#L27-L44 |
dmishh/SettingsBundle | Controller/SettingsController.php | SettingsController.manageOwnAction | public function manageOwnAction(Request $request)
{
$securityContext = $this->getSecurityContext();
if (!$securityContext->getToken()) {
throw new AccessDeniedException(
$this->get('translator')->trans(
'must_be_logged_in_to_edit_own_settings',
array(),
'settings'
)
);
}
$securitySettings = $this->container->getParameter('settings_manager.security');
if (!$securitySettings['users_can_manage_own_settings']) {
throw new AccessDeniedException(
$this->get('translator')->trans(
'not_allowed_to_edit_own_settings',
array(),
'settings'
)
);
}
$user = $securityContext->getToken()->getUser();
if (!($user instanceof SettingsOwnerInterface)) {
//For this to work the User entity must implement SettingsOwnerInterface
throw new AccessDeniedException();
}
return $this->manage($request, $user);
} | php | public function manageOwnAction(Request $request)
{
$securityContext = $this->getSecurityContext();
if (!$securityContext->getToken()) {
throw new AccessDeniedException(
$this->get('translator')->trans(
'must_be_logged_in_to_edit_own_settings',
array(),
'settings'
)
);
}
$securitySettings = $this->container->getParameter('settings_manager.security');
if (!$securitySettings['users_can_manage_own_settings']) {
throw new AccessDeniedException(
$this->get('translator')->trans(
'not_allowed_to_edit_own_settings',
array(),
'settings'
)
);
}
$user = $securityContext->getToken()->getUser();
if (!($user instanceof SettingsOwnerInterface)) {
//For this to work the User entity must implement SettingsOwnerInterface
throw new AccessDeniedException();
}
return $this->manage($request, $user);
} | [
"public",
"function",
"manageOwnAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"securityContext",
"=",
"$",
"this",
"->",
"getSecurityContext",
"(",
")",
";",
"if",
"(",
"!",
"$",
"securityContext",
"->",
"getToken",
"(",
")",
")",
"{",
"throw",
... | @param Request $request
@return \Symfony\Component\HttpFoundation\Response
@throws \Symfony\Component\Security\Core\Exception\AccessDeniedException | [
"@param",
"Request",
"$request"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Controller/SettingsController.php#L53-L86 |
dmishh/SettingsBundle | Controller/SettingsController.php | SettingsController.manage | protected function manage(Request $request, SettingsOwnerInterface $owner = null)
{
$form = $this->createForm(SettingsType::class, $this->get('settings_manager')->all($owner));
if ($request->isMethod('post')) {
$form->handleRequest($request);
if ($form->isValid()) {
$this->get('settings_manager')->setMany($form->getData(), $owner);
$this->get('session')->getFlashBag()->add(
'success',
$this->get('translator')->trans('settings_updated', array(), 'settings')
);
return $this->redirect($request->getUri());
}
}
return $this->render(
$this->container->getParameter('settings_manager.template'),
array(
'settings_form' => $form->createView(),
)
);
} | php | protected function manage(Request $request, SettingsOwnerInterface $owner = null)
{
$form = $this->createForm(SettingsType::class, $this->get('settings_manager')->all($owner));
if ($request->isMethod('post')) {
$form->handleRequest($request);
if ($form->isValid()) {
$this->get('settings_manager')->setMany($form->getData(), $owner);
$this->get('session')->getFlashBag()->add(
'success',
$this->get('translator')->trans('settings_updated', array(), 'settings')
);
return $this->redirect($request->getUri());
}
}
return $this->render(
$this->container->getParameter('settings_manager.template'),
array(
'settings_form' => $form->createView(),
)
);
} | [
"protected",
"function",
"manage",
"(",
"Request",
"$",
"request",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"SettingsType",
"::",
"class",
",",
"$",
"this",
"->",
"get",
"... | @param Request $request
@param SettingsOwnerInterface|null $owner
@return \Symfony\Component\HttpFoundation\Response | [
"@param",
"Request",
"$request",
"@param",
"SettingsOwnerInterface|null",
"$owner"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Controller/SettingsController.php#L94-L118 |
dmishh/SettingsBundle | Serializer/SerializerFactory.php | SerializerFactory.create | public static function create($name)
{
$serializerClass = 'Dmishh\\SettingsBundle\\Serializer\\' . Container::camelize($name) . 'Serializer';
if (class_exists($serializerClass)) {
return new $serializerClass();
} else {
$serializerClass = $name;
if (class_exists($serializerClass)) {
$serializer = new $serializerClass();
if ($serializer instanceof SerializerInterface) {
return $serializer;
}
}
}
throw new UnknownSerializerException($serializerClass);
} | php | public static function create($name)
{
$serializerClass = 'Dmishh\\SettingsBundle\\Serializer\\' . Container::camelize($name) . 'Serializer';
if (class_exists($serializerClass)) {
return new $serializerClass();
} else {
$serializerClass = $name;
if (class_exists($serializerClass)) {
$serializer = new $serializerClass();
if ($serializer instanceof SerializerInterface) {
return $serializer;
}
}
}
throw new UnknownSerializerException($serializerClass);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"serializerClass",
"=",
"'Dmishh\\\\SettingsBundle\\\\Serializer\\\\'",
".",
"Container",
"::",
"camelize",
"(",
"$",
"name",
")",
".",
"'Serializer'",
";",
"if",
"(",
"class_exists",
"("... | @param string $name short name of serializer (ex.: php) or full class name
@throws \Dmishh\SettingsBundle\Exception\UnknownSerializerException
@return SerializerInterface | [
"@param",
"string",
"$name",
"short",
"name",
"of",
"serializer",
"(",
"ex",
".",
":",
"php",
")",
"or",
"full",
"class",
"name"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Serializer/SerializerFactory.php#L26-L44 |
dmishh/SettingsBundle | Form/Type/SettingsType.php | SettingsType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($this->settingsConfiguration as $name => $configuration) {
// If setting's value exists in data and setting isn't disabled
if (array_key_exists($name, $options['data']) && !in_array($name, $options['disabled_settings'])) {
$fieldType = $configuration['type'];
$fieldOptions = $configuration['options'];
$fieldOptions['constraints'] = $configuration['constraints'];
// Validator constraints
if (!empty($fieldOptions['constraints']) && is_array($fieldOptions['constraints'])) {
$constraints = array();
foreach ($fieldOptions['constraints'] as $class => $constraintOptions) {
if (class_exists($class)) {
$constraints[] = new $class($constraintOptions);
} else {
throw new SettingsException(sprintf('Constraint class "%s" not found', $class));
}
}
$fieldOptions['constraints'] = $constraints;
}
// Label I18n
$fieldOptions['label'] = 'labels.'.$name;
$fieldOptions['translation_domain'] = 'settings';
// Choices I18n
if (!empty($fieldOptions['choices'])) {
$fieldOptions['choices'] = array_map(
function ($label) use ($fieldOptions) {
return $fieldOptions['label'].'_choices.'.$label;
},
array_combine($fieldOptions['choices'], $fieldOptions['choices'])
);
}
$builder->add($name, $fieldType, $fieldOptions);
}
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($this->settingsConfiguration as $name => $configuration) {
// If setting's value exists in data and setting isn't disabled
if (array_key_exists($name, $options['data']) && !in_array($name, $options['disabled_settings'])) {
$fieldType = $configuration['type'];
$fieldOptions = $configuration['options'];
$fieldOptions['constraints'] = $configuration['constraints'];
// Validator constraints
if (!empty($fieldOptions['constraints']) && is_array($fieldOptions['constraints'])) {
$constraints = array();
foreach ($fieldOptions['constraints'] as $class => $constraintOptions) {
if (class_exists($class)) {
$constraints[] = new $class($constraintOptions);
} else {
throw new SettingsException(sprintf('Constraint class "%s" not found', $class));
}
}
$fieldOptions['constraints'] = $constraints;
}
// Label I18n
$fieldOptions['label'] = 'labels.'.$name;
$fieldOptions['translation_domain'] = 'settings';
// Choices I18n
if (!empty($fieldOptions['choices'])) {
$fieldOptions['choices'] = array_map(
function ($label) use ($fieldOptions) {
return $fieldOptions['label'].'_choices.'.$label;
},
array_combine($fieldOptions['choices'], $fieldOptions['choices'])
);
}
$builder->add($name, $fieldType, $fieldOptions);
}
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"settingsConfiguration",
"as",
"$",
"name",
"=>",
"$",
"configuration",
")",
"{",
"// If setting's value ex... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Form/Type/SettingsType.php#L37-L76 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.get | public function get($name, SettingsOwnerInterface $owner = null, $default = null)
{
$this->validateSetting($name, $owner);
$this->loadSettings($owner);
$value = null;
switch ($this->settingsConfiguration[$name]['scope']) {
case SettingsManagerInterface::SCOPE_GLOBAL:
$value = $this->globalSettings[$name];
break;
case SettingsManagerInterface::SCOPE_ALL:
$value = $this->globalSettings[$name];
//Do not break here. Try to fetch the users settings
case SettingsManagerInterface::SCOPE_USER:
if ($owner !== null) {
if ($this->ownerSettings[$owner->getSettingIdentifier()][$name] !== null) {
$value = $this->ownerSettings[$owner->getSettingIdentifier()][$name];
}
}
break;
}
return $value === null ? $default : $value;
} | php | public function get($name, SettingsOwnerInterface $owner = null, $default = null)
{
$this->validateSetting($name, $owner);
$this->loadSettings($owner);
$value = null;
switch ($this->settingsConfiguration[$name]['scope']) {
case SettingsManagerInterface::SCOPE_GLOBAL:
$value = $this->globalSettings[$name];
break;
case SettingsManagerInterface::SCOPE_ALL:
$value = $this->globalSettings[$name];
//Do not break here. Try to fetch the users settings
case SettingsManagerInterface::SCOPE_USER:
if ($owner !== null) {
if ($this->ownerSettings[$owner->getSettingIdentifier()][$name] !== null) {
$value = $this->ownerSettings[$owner->getSettingIdentifier()][$name];
}
}
break;
}
return $value === null ? $default : $value;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"validateSetting",
"(",
"$",
"name",
",",
"$",
"owner",
")",
";",
"$",
"this",
"->... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L76-L100 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.all | public function all(SettingsOwnerInterface $owner = null)
{
$this->loadSettings($owner);
if ($owner === null) {
return $this->globalSettings;
}
$settings = $this->ownerSettings[$owner->getSettingIdentifier()];
// If some user setting is not defined, please use the value from global
foreach ($settings as $key => $value) {
if ($value === null && isset($this->globalSettings[$key])) {
$settings[$key] = $this->globalSettings[$key];
}
}
return $settings;
} | php | public function all(SettingsOwnerInterface $owner = null)
{
$this->loadSettings($owner);
if ($owner === null) {
return $this->globalSettings;
}
$settings = $this->ownerSettings[$owner->getSettingIdentifier()];
// If some user setting is not defined, please use the value from global
foreach ($settings as $key => $value) {
if ($value === null && isset($this->globalSettings[$key])) {
$settings[$key] = $this->globalSettings[$key];
}
}
return $settings;
} | [
"public",
"function",
"all",
"(",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"loadSettings",
"(",
"$",
"owner",
")",
";",
"if",
"(",
"$",
"owner",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"globalSetti... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L105-L123 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.set | public function set($name, $value, SettingsOwnerInterface $owner = null)
{
$this->setWithoutFlush($name, $value, $owner);
return $this->flush($name, $owner);
} | php | public function set($name, $value, SettingsOwnerInterface $owner = null)
{
$this->setWithoutFlush($name, $value, $owner);
return $this->flush($name, $owner);
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setWithoutFlush",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"owner",
")",
";",
"return",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L128-L133 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.setMany | public function setMany(array $settings, SettingsOwnerInterface $owner = null)
{
foreach ($settings as $name => $value) {
$this->setWithoutFlush($name, $value, $owner);
}
return $this->flush(array_keys($settings), $owner);
} | php | public function setMany(array $settings, SettingsOwnerInterface $owner = null)
{
foreach ($settings as $name => $value) {
$this->setWithoutFlush($name, $value, $owner);
}
return $this->flush(array_keys($settings), $owner);
} | [
"public",
"function",
"setMany",
"(",
"array",
"$",
"settings",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setWithoutFlush",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L138-L145 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.clear | public function clear($name, SettingsOwnerInterface $owner = null)
{
return $this->set($name, null, $owner);
} | php | public function clear($name, SettingsOwnerInterface $owner = null)
{
return $this->set($name, null, $owner);
} | [
"public",
"function",
"clear",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"null",
",",
"$",
"owner",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L150-L153 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.setWithoutFlush | private function setWithoutFlush($name, $value, SettingsOwnerInterface $owner = null)
{
$this->validateSetting($name, $owner);
$this->loadSettings($owner);
if ($owner === null) {
$this->globalSettings[$name] = $value;
} else {
$this->ownerSettings[$owner->getSettingIdentifier()][$name] = $value;
}
return $this;
} | php | private function setWithoutFlush($name, $value, SettingsOwnerInterface $owner = null)
{
$this->validateSetting($name, $owner);
$this->loadSettings($owner);
if ($owner === null) {
$this->globalSettings[$name] = $value;
} else {
$this->ownerSettings[$owner->getSettingIdentifier()][$name] = $value;
}
return $this;
} | [
"private",
"function",
"setWithoutFlush",
"(",
"$",
"name",
",",
"$",
"value",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"validateSetting",
"(",
"$",
"name",
",",
"$",
"owner",
")",
";",
"$",
"this",
"->",
"... | Sets setting value to private array. Used for settings' batch saving.
@param string $name
@param mixed $value
@param SettingsOwnerInterface|null $owner
@return SettingsManager | [
"Sets",
"setting",
"value",
"to",
"private",
"array",
".",
"Used",
"for",
"settings",
"batch",
"saving",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L164-L176 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.flush | private function flush($names, SettingsOwnerInterface $owner = null)
{
$names = (array)$names;
$settings = $this->repository->findBy(
array(
'name' => $names,
'ownerId' => $owner === null ? null : $owner->getSettingIdentifier(),
)
);
// Assert: $settings might be a smaller set than $names
// For each settings that you are trying to save
foreach ($names as $name) {
try {
$value = $this->get($name, $owner);
} catch (WrongScopeException $e) {
continue;
}
/** @var Setting $setting */
$setting = $this->findSettingByName($settings, $name);
if (!$setting) {
// if the setting does not exist in DB, create it
$setting = new Setting();
$setting->setName($name);
if ($owner !== null) {
$setting->setOwnerId($owner->getSettingIdentifier());
}
$this->em->persist($setting);
}
$setting->setValue($this->serializer->serialize($value));
}
$this->em->flush();
return $this;
} | php | private function flush($names, SettingsOwnerInterface $owner = null)
{
$names = (array)$names;
$settings = $this->repository->findBy(
array(
'name' => $names,
'ownerId' => $owner === null ? null : $owner->getSettingIdentifier(),
)
);
// Assert: $settings might be a smaller set than $names
// For each settings that you are trying to save
foreach ($names as $name) {
try {
$value = $this->get($name, $owner);
} catch (WrongScopeException $e) {
continue;
}
/** @var Setting $setting */
$setting = $this->findSettingByName($settings, $name);
if (!$setting) {
// if the setting does not exist in DB, create it
$setting = new Setting();
$setting->setName($name);
if ($owner !== null) {
$setting->setOwnerId($owner->getSettingIdentifier());
}
$this->em->persist($setting);
}
$setting->setValue($this->serializer->serialize($value));
}
$this->em->flush();
return $this;
} | [
"private",
"function",
"flush",
"(",
"$",
"names",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"names",
"=",
"(",
"array",
")",
"$",
"names",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"repository",
"->",
"findBy",
"(",
... | Flushes settings defined by $names to database.
@param string|array $names
@param SettingsOwnerInterface|null $owner
@throws \Dmishh\SettingsBundle\Exception\UnknownSerializerException
@return SettingsManager | [
"Flushes",
"settings",
"defined",
"by",
"$names",
"to",
"database",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L188-L228 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.findSettingByName | protected function findSettingByName($haystack, $needle)
{
foreach ($haystack as $setting) {
if ($setting->getName() === $needle) {
return $setting;
}
}
} | php | protected function findSettingByName($haystack, $needle)
{
foreach ($haystack as $setting) {
if ($setting->getName() === $needle) {
return $setting;
}
}
} | [
"protected",
"function",
"findSettingByName",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"setting",
")",
"{",
"if",
"(",
"$",
"setting",
"->",
"getName",
"(",
")",
"===",
"$",
"needle",
")",
"{",
"... | Find a setting by name form an array of settings.
@param Setting[] $haystack
@param string $needle
@return Setting|null | [
"Find",
"a",
"setting",
"by",
"name",
"form",
"an",
"array",
"of",
"settings",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L238-L245 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.validateSetting | private function validateSetting($name, SettingsOwnerInterface $owner = null)
{
// Name validation
if (!is_string($name) || !array_key_exists($name, $this->settingsConfiguration)) {
throw new UnknownSettingException($name);
}
// Scope validation
$scope = $this->settingsConfiguration[$name]['scope'];
if ($scope !== SettingsManagerInterface::SCOPE_ALL) {
if ($scope === SettingsManagerInterface::SCOPE_GLOBAL && $owner !== null || $scope === SettingsManagerInterface::SCOPE_USER && $owner === null) {
throw new WrongScopeException($scope, $name);
}
}
return $this;
} | php | private function validateSetting($name, SettingsOwnerInterface $owner = null)
{
// Name validation
if (!is_string($name) || !array_key_exists($name, $this->settingsConfiguration)) {
throw new UnknownSettingException($name);
}
// Scope validation
$scope = $this->settingsConfiguration[$name]['scope'];
if ($scope !== SettingsManagerInterface::SCOPE_ALL) {
if ($scope === SettingsManagerInterface::SCOPE_GLOBAL && $owner !== null || $scope === SettingsManagerInterface::SCOPE_USER && $owner === null) {
throw new WrongScopeException($scope, $name);
}
}
return $this;
} | [
"private",
"function",
"validateSetting",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"// Name validation",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
... | Checks that $name is valid setting and it's scope is also valid.
@param string $name
@param SettingsOwnerInterface $owner
@return SettingsManager
@throws \Dmishh\SettingsBundle\Exception\UnknownSettingException
@throws \Dmishh\SettingsBundle\Exception\WrongScopeException | [
"Checks",
"that",
"$name",
"is",
"valid",
"setting",
"and",
"it",
"s",
"scope",
"is",
"also",
"valid",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L258-L274 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.loadSettings | private function loadSettings(SettingsOwnerInterface $owner = null)
{
// Global settings
if ($this->globalSettings === null) {
$this->globalSettings = $this->getSettingsFromRepository();
}
// User settings
if ($owner !== null && ($this->ownerSettings === null || !array_key_exists(
$owner->getSettingIdentifier(),
$this->ownerSettings
))
) {
$this->ownerSettings[$owner->getSettingIdentifier()] = $this->getSettingsFromRepository($owner);
}
return $this;
} | php | private function loadSettings(SettingsOwnerInterface $owner = null)
{
// Global settings
if ($this->globalSettings === null) {
$this->globalSettings = $this->getSettingsFromRepository();
}
// User settings
if ($owner !== null && ($this->ownerSettings === null || !array_key_exists(
$owner->getSettingIdentifier(),
$this->ownerSettings
))
) {
$this->ownerSettings[$owner->getSettingIdentifier()] = $this->getSettingsFromRepository($owner);
}
return $this;
} | [
"private",
"function",
"loadSettings",
"(",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"// Global settings",
"if",
"(",
"$",
"this",
"->",
"globalSettings",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"globalSettings",
"=",
"$",
"this",
"... | Settings lazy loading.
@param SettingsOwnerInterface|null $owner
@return SettingsManager | [
"Settings",
"lazy",
"loading",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L283-L300 |
dmishh/SettingsBundle | Manager/SettingsManager.php | SettingsManager.getSettingsFromRepository | private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
{
$settings = array();
foreach (array_keys($this->settingsConfiguration) as $name) {
try {
$this->validateSetting($name, $owner);
$settings[$name] = null;
} catch (WrongScopeException $e) {
continue;
}
}
/** @var Setting $setting */
foreach ($this->repository->findBy(
array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
) as $setting) {
if (array_key_exists($setting->getName(), $settings)) {
$settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
}
}
return $settings;
} | php | private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
{
$settings = array();
foreach (array_keys($this->settingsConfiguration) as $name) {
try {
$this->validateSetting($name, $owner);
$settings[$name] = null;
} catch (WrongScopeException $e) {
continue;
}
}
/** @var Setting $setting */
foreach ($this->repository->findBy(
array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
) as $setting) {
if (array_key_exists($setting->getName(), $settings)) {
$settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
}
}
return $settings;
} | [
"private",
"function",
"getSettingsFromRepository",
"(",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"settings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"settingsConfiguration",
")",
"as",
"$",... | Retreives settings from repository.
@param SettingsOwnerInterface|null $owner
@throws \Dmishh\SettingsBundle\Exception\UnknownSerializerException
@return array | [
"Retreives",
"settings",
"from",
"repository",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/SettingsManager.php#L311-L334 |
dmishh/SettingsBundle | DependencyInjection/DmishhSettingsExtension.php | DmishhSettingsExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
foreach ($config as $key => $value) {
$container->setParameter('settings_manager.'.$key, $value);
}
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
// Configure the correct storage
if ($config['cache_service'] === null) {
$container->removeDefinition('dmishh.settings.cached_settings_manager');
} else {
$container->getDefinition('dmishh.settings.cached_settings_manager')
->replaceArgument(1, new Reference($config['cache_service']))
->replaceArgument(2, $config['cache_lifetime']);
// set an alias to make sure the cached settings manager is the default
$container->setAlias('settings_manager', 'dmishh.settings.cached_settings_manager');
}
} | php | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
foreach ($config as $key => $value) {
$container->setParameter('settings_manager.'.$key, $value);
}
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
// Configure the correct storage
if ($config['cache_service'] === null) {
$container->removeDefinition('dmishh.settings.cached_settings_manager');
} else {
$container->getDefinition('dmishh.settings.cached_settings_manager')
->replaceArgument(1, new Reference($config['cache_service']))
->replaceArgument(2, $config['cache_lifetime']);
// set an alias to make sure the cached settings manager is the default
$container->setAlias('settings_manager', 'dmishh.settings.cached_settings_manager');
}
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"con... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/DependencyInjection/DmishhSettingsExtension.php#L30-L53 |
dmishh/SettingsBundle | Twig/SettingsExtension.php | SettingsExtension.getSetting | public function getSetting($name, SettingsOwnerInterface $owner = null, $default = null)
{
return $this->settingsManager->get($name, $owner, $default);
} | php | public function getSetting($name, SettingsOwnerInterface $owner = null, $default = null)
{
return $this->settingsManager->get($name, $owner, $default);
} | [
"public",
"function",
"getSetting",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"settingsManager",
"->",
"get",
"(",
"$",
"name",
",",
"$",
"owner",
... | Proxy to SettingsManager::get.
@param string $name
@param SettingsOwnerInterface|null $owner
@return mixed | [
"Proxy",
"to",
"SettingsManager",
"::",
"get",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Twig/SettingsExtension.php#L48-L51 |
dmishh/SettingsBundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('dmishh_settings');
$scopes = array(
SettingsManagerInterface::SCOPE_ALL,
SettingsManagerInterface::SCOPE_GLOBAL,
SettingsManagerInterface::SCOPE_USER,
);
$rootNode
->children()
->scalarNode('template')
->defaultValue('DmishhSettingsBundle:Settings:manage.html.twig')
->end()
->scalarNode('cache_service')->defaultNull()->info('A service implementing Psr\Cache\CacheItemPoolInterface')->end()
->integerNode('cache_lifetime')->defaultValue(3600)->end()
->arrayNode('security')
->addDefaultsIfNotSet()
->children()
->scalarNode('manage_global_settings_role')->end()
->booleanNode('users_can_manage_own_settings')->defaultValue(true)->end()
->end()
->end()
->enumNode('serialization')
->defaultValue('php')
->values(array('php', 'json'))
->end()
->arrayNode('settings')
->prototype('array')
->addDefaultsIfNotSet()
->children()
->scalarNode('scope')
->defaultValue('all')
->validate()
->ifNotInArray($scopes)
->thenInvalid('Invalid scope %s. Valid scopes are: '.implode(', ', array_map(function ($s) { return '"'.$s.'"'; }, $scopes)).'.')
->end()
->end()
->scalarNode('type')->defaultValue('text')->end()
->variableNode('options')
->info('The options given to the form builder')
->defaultValue(array())
->validate()
->always(function ($v) {
if (!is_array($v)) {
throw new InvalidTypeException();
}
return $v;
})
->end()
->end()
->variableNode('constraints')
->info('The constraints on this option. Example, use constraits found in Symfony\Component\Validator\Constraints')
->defaultValue(array())
->validate()
->always(function ($v) {
if (!is_array($v)) {
throw new InvalidTypeException();
}
return $v;
})
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('dmishh_settings');
$scopes = array(
SettingsManagerInterface::SCOPE_ALL,
SettingsManagerInterface::SCOPE_GLOBAL,
SettingsManagerInterface::SCOPE_USER,
);
$rootNode
->children()
->scalarNode('template')
->defaultValue('DmishhSettingsBundle:Settings:manage.html.twig')
->end()
->scalarNode('cache_service')->defaultNull()->info('A service implementing Psr\Cache\CacheItemPoolInterface')->end()
->integerNode('cache_lifetime')->defaultValue(3600)->end()
->arrayNode('security')
->addDefaultsIfNotSet()
->children()
->scalarNode('manage_global_settings_role')->end()
->booleanNode('users_can_manage_own_settings')->defaultValue(true)->end()
->end()
->end()
->enumNode('serialization')
->defaultValue('php')
->values(array('php', 'json'))
->end()
->arrayNode('settings')
->prototype('array')
->addDefaultsIfNotSet()
->children()
->scalarNode('scope')
->defaultValue('all')
->validate()
->ifNotInArray($scopes)
->thenInvalid('Invalid scope %s. Valid scopes are: '.implode(', ', array_map(function ($s) { return '"'.$s.'"'; }, $scopes)).'.')
->end()
->end()
->scalarNode('type')->defaultValue('text')->end()
->variableNode('options')
->info('The options given to the form builder')
->defaultValue(array())
->validate()
->always(function ($v) {
if (!is_array($v)) {
throw new InvalidTypeException();
}
return $v;
})
->end()
->end()
->variableNode('constraints')
->info('The constraints on this option. Example, use constraits found in Symfony\Component\Validator\Constraints')
->defaultValue(array())
->validate()
->always(function ($v) {
if (!is_array($v)) {
throw new InvalidTypeException();
}
return $v;
})
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'dmishh_settings'",
")",
";",
"$",
"scopes",
"=",
"array",
"(",
"Settin... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/DependencyInjection/Configuration.php#L24-L98 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.get | public function get($name, SettingsOwnerInterface $owner = null, $default = null)
{
if (null !== $cached = $this->fetchFromCache($name, $owner)) {
return $cached;
}
$value = $this->settingsManager->get($name, $owner, $default);
$this->storeInCache($name, $value, $owner);
return $value;
} | php | public function get($name, SettingsOwnerInterface $owner = null, $default = null)
{
if (null !== $cached = $this->fetchFromCache($name, $owner)) {
return $cached;
}
$value = $this->settingsManager->get($name, $owner, $default);
$this->storeInCache($name, $value, $owner);
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"cached",
"=",
"$",
"this",
"->",
"fetchFromCache",
"(",
"$",
"name",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L50-L60 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.all | public function all(SettingsOwnerInterface $owner = null)
{
if (null !== $cached = $this->fetchFromCache(null, $owner)) {
return $cached;
}
$value = $this->settingsManager->all($owner);
$this->storeInCache(null, $value, $owner);
return $value;
} | php | public function all(SettingsOwnerInterface $owner = null)
{
if (null !== $cached = $this->fetchFromCache(null, $owner)) {
return $cached;
}
$value = $this->settingsManager->all($owner);
$this->storeInCache(null, $value, $owner);
return $value;
} | [
"public",
"function",
"all",
"(",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"cached",
"=",
"$",
"this",
"->",
"fetchFromCache",
"(",
"null",
",",
"$",
"owner",
")",
")",
"{",
"return",
"$",
"cached",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L65-L75 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.set | public function set($name, $value, SettingsOwnerInterface $owner = null)
{
$this->invalidateCache($name, $owner);
$this->invalidateCache(null, $owner);
return $this->settingsManager->set($name, $value, $owner);
} | php | public function set($name, $value, SettingsOwnerInterface $owner = null)
{
$this->invalidateCache($name, $owner);
$this->invalidateCache(null, $owner);
return $this->settingsManager->set($name, $value, $owner);
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"invalidateCache",
"(",
"$",
"name",
",",
"$",
"owner",
")",
";",
"$",
"this",
"->",
"invalidateCac... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L80-L86 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.setMany | public function setMany(array $settings, SettingsOwnerInterface $owner = null)
{
foreach ($settings as $key => $value) {
$this->invalidateCache($key, $owner);
}
$this->invalidateCache(null, $owner);
return $this->settingsManager->setMany($settings, $owner);
} | php | public function setMany(array $settings, SettingsOwnerInterface $owner = null)
{
foreach ($settings as $key => $value) {
$this->invalidateCache($key, $owner);
}
$this->invalidateCache(null, $owner);
return $this->settingsManager->setMany($settings, $owner);
} | [
"public",
"function",
"setMany",
"(",
"array",
"$",
"settings",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"invalidateCache",
"("... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L91-L99 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.clear | public function clear($name, SettingsOwnerInterface $owner = null)
{
$this->invalidateCache($name, $owner);
$this->invalidateCache(null, $owner);
return $this->settingsManager->clear($name, $owner);
} | php | public function clear($name, SettingsOwnerInterface $owner = null)
{
$this->invalidateCache($name, $owner);
$this->invalidateCache(null, $owner);
return $this->settingsManager->clear($name, $owner);
} | [
"public",
"function",
"clear",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"invalidateCache",
"(",
"$",
"name",
",",
"$",
"owner",
")",
";",
"$",
"this",
"->",
"invalidateCache",
"(",
"null",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L104-L110 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.invalidateCache | protected function invalidateCache($name, SettingsOwnerInterface $owner = null)
{
return $this->storage->deleteItem($this->getCacheKey($name, $owner));
} | php | protected function invalidateCache($name, SettingsOwnerInterface $owner = null)
{
return $this->storage->deleteItem($this->getCacheKey($name, $owner));
} | [
"protected",
"function",
"invalidateCache",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"storage",
"->",
"deleteItem",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
"$",
"name",
",",
"$",... | @param SettingsOwnerInterface $owner
@param string $name
@return bool TRUE if the cache entry was successfully deleted, FALSE otherwise. | [
"@param",
"SettingsOwnerInterface",
"$owner",
"@param",
"string",
"$name"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L118-L121 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.fetchFromCache | protected function fetchFromCache($name, SettingsOwnerInterface $owner = null)
{
$cacheKey = $this->getCacheKey($name, $owner);
return $this->storage->getItem($cacheKey)->get();
} | php | protected function fetchFromCache($name, SettingsOwnerInterface $owner = null)
{
$cacheKey = $this->getCacheKey($name, $owner);
return $this->storage->getItem($cacheKey)->get();
} | [
"protected",
"function",
"fetchFromCache",
"(",
"$",
"name",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
"$",
"name",
",",
"$",
"owner",
")",
";",
"return",
"$",
"this",... | Get from cache.
@param SettingsOwnerInterface $owner
@param string $name
@return mixed|null if nothing was found in cache | [
"Get",
"from",
"cache",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L131-L136 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.storeInCache | protected function storeInCache($name, $value, SettingsOwnerInterface $owner = null)
{
$item = $this->storage->getItem($this->getCacheKey($name, $owner))
->set($value)
->expiresAfter($this->cacheLifeTime);
return $this->storage->save($item);
} | php | protected function storeInCache($name, $value, SettingsOwnerInterface $owner = null)
{
$item = $this->storage->getItem($this->getCacheKey($name, $owner))
->set($value)
->expiresAfter($this->cacheLifeTime);
return $this->storage->save($item);
} | [
"protected",
"function",
"storeInCache",
"(",
"$",
"name",
",",
"$",
"value",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"storage",
"->",
"getItem",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",... | Store in cache.
@param SettingsOwnerInterface $owner
@param string $name
@param mixed $value
@return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise. | [
"Store",
"in",
"cache",
"."
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L147-L154 |
dmishh/SettingsBundle | Manager/CachedSettingsManager.php | CachedSettingsManager.getCacheKey | protected function getCacheKey($key, SettingsOwnerInterface $owner = null)
{
return sprintf(self::PREFIX, $owner ? $owner->getSettingIdentifier() : '', $key);
} | php | protected function getCacheKey($key, SettingsOwnerInterface $owner = null)
{
return sprintf(self::PREFIX, $owner ? $owner->getSettingIdentifier() : '', $key);
} | [
"protected",
"function",
"getCacheKey",
"(",
"$",
"key",
",",
"SettingsOwnerInterface",
"$",
"owner",
"=",
"null",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"PREFIX",
",",
"$",
"owner",
"?",
"$",
"owner",
"->",
"getSettingIdentifier",
"(",
")",
":"... | @param string $key
@param SettingsOwnerInterface $owner
@return string | [
"@param",
"string",
"$key",
"@param",
"SettingsOwnerInterface",
"$owner"
] | train | https://github.com/dmishh/SettingsBundle/blob/0ee48b015691694a8dcbd3ee654d33386e7bf478/Manager/CachedSettingsManager.php#L162-L165 |
ConsoleTVs/Invoices | Classes/PDF.php | PDF.generate | public static function generate(Invoice $invoice, $template = 'default')
{
$template = strtolower($template);
$options = new Options();
$options->set('isRemoteEnabled', true);
$pdf = new Dompdf($options);
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed'=> true,
],
]);
$pdf->setHttpContext($context);
$pdf->loadHtml(View::make('invoices::'.$template, ['invoice' => $invoice]));
$pdf->render();
return $pdf;
} | php | public static function generate(Invoice $invoice, $template = 'default')
{
$template = strtolower($template);
$options = new Options();
$options->set('isRemoteEnabled', true);
$pdf = new Dompdf($options);
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed'=> true,
],
]);
$pdf->setHttpContext($context);
$pdf->loadHtml(View::make('invoices::'.$template, ['invoice' => $invoice]));
$pdf->render();
return $pdf;
} | [
"public",
"static",
"function",
"generate",
"(",
"Invoice",
"$",
"invoice",
",",
"$",
"template",
"=",
"'default'",
")",
"{",
"$",
"template",
"=",
"strtolower",
"(",
"$",
"template",
")",
";",
"$",
"options",
"=",
"new",
"Options",
"(",
")",
";",
"$",... | Generate the PDF.
@method generate
@param ConsoleTVs\Invoices\Classes\Invoice $invoice
@param string $template
@return Dompdf\Dompdf | [
"Generate",
"the",
"PDF",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/PDF.php#L34-L58 |
ConsoleTVs/Invoices | Classes/Invoice.php | Invoice.addItem | public function addItem($name, $price, $ammount = 1, $id = '-')
{
$this->items->push(Collection::make([
'name' => $name,
'price' => $price,
'ammount' => $ammount,
'totalPrice' => number_format(bcmul($price, $ammount, $this->decimals), $this->decimals),
'id' => $id,
]));
return $this;
} | php | public function addItem($name, $price, $ammount = 1, $id = '-')
{
$this->items->push(Collection::make([
'name' => $name,
'price' => $price,
'ammount' => $ammount,
'totalPrice' => number_format(bcmul($price, $ammount, $this->decimals), $this->decimals),
'id' => $id,
]));
return $this;
} | [
"public",
"function",
"addItem",
"(",
"$",
"name",
",",
"$",
"price",
",",
"$",
"ammount",
"=",
"1",
",",
"$",
"id",
"=",
"'-'",
")",
"{",
"$",
"this",
"->",
"items",
"->",
"push",
"(",
"Collection",
"::",
"make",
"(",
"[",
"'name'",
"=>",
"$",
... | Adds an item to the invoice.
@method addItem
@param string $name
@param int $price
@param int $ammount
@param string $id
@return self | [
"Adds",
"an",
"item",
"to",
"the",
"invoice",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/Invoice.php#L181-L192 |
ConsoleTVs/Invoices | Classes/Invoice.php | Invoice.formatCurrency | public function formatCurrency()
{
$currencies = json_decode(file_get_contents(__DIR__.'/../Currencies.json'));
$currency = $this->currency;
return $currencies->$currency;
} | php | public function formatCurrency()
{
$currencies = json_decode(file_get_contents(__DIR__.'/../Currencies.json'));
$currency = $this->currency;
return $currencies->$currency;
} | [
"public",
"function",
"formatCurrency",
"(",
")",
"{",
"$",
"currencies",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../Currencies.json'",
")",
")",
";",
"$",
"currency",
"=",
"$",
"this",
"->",
"currency",
";",
"return",
"$",
"cur... | Return the currency object.
@method formatCurrency
@return stdClass | [
"Return",
"the",
"currency",
"object",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/Invoice.php#L215-L221 |
ConsoleTVs/Invoices | Classes/Invoice.php | Invoice.subTotalPrice | private function subTotalPrice()
{
return $this->items->sum(function ($item) {
return bcmul($item['price'], $item['ammount'], $this->decimals);
});
} | php | private function subTotalPrice()
{
return $this->items->sum(function ($item) {
return bcmul($item['price'], $item['ammount'], $this->decimals);
});
} | [
"private",
"function",
"subTotalPrice",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"->",
"sum",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"bcmul",
"(",
"$",
"item",
"[",
"'price'",
"]",
",",
"$",
"item",
"[",
"'ammount'",
"]",
... | Return the subtotal invoice price.
@method subTotalPrice
@return int | [
"Return",
"the",
"subtotal",
"invoice",
"price",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/Invoice.php#L230-L235 |
ConsoleTVs/Invoices | Classes/Invoice.php | Invoice.taxPrice | private function taxPrice()
{
if ($this->tax_type == 'percentage') {
return bcdiv(bcmul($this->tax, $this->subTotalPrice(), $this->decimals), 100, $this->decimals);
}
return $this->tax;
} | php | private function taxPrice()
{
if ($this->tax_type == 'percentage') {
return bcdiv(bcmul($this->tax, $this->subTotalPrice(), $this->decimals), 100, $this->decimals);
}
return $this->tax;
} | [
"private",
"function",
"taxPrice",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tax_type",
"==",
"'percentage'",
")",
"{",
"return",
"bcdiv",
"(",
"bcmul",
"(",
"$",
"this",
"->",
"tax",
",",
"$",
"this",
"->",
"subTotalPrice",
"(",
")",
",",
"$",
... | taxPrice.
@method taxPrice
@return float | [
"taxPrice",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/Invoice.php#L280-L287 |
ConsoleTVs/Invoices | Classes/Invoice.php | Invoice.save | public function save($name = 'invoice.pdf')
{
$invoice = $this->generate();
Storage::put($name, $invoice->pdf->output());
} | php | public function save($name = 'invoice.pdf')
{
$invoice = $this->generate();
Storage::put($name, $invoice->pdf->output());
} | [
"public",
"function",
"save",
"(",
"$",
"name",
"=",
"'invoice.pdf'",
")",
"{",
"$",
"invoice",
"=",
"$",
"this",
"->",
"generate",
"(",
")",
";",
"Storage",
"::",
"put",
"(",
"$",
"name",
",",
"$",
"invoice",
"->",
"pdf",
"->",
"output",
"(",
")",... | Save the generated PDF.
@method save
@param string $name | [
"Save",
"the",
"generated",
"PDF",
"."
] | train | https://github.com/ConsoleTVs/Invoices/blob/f0d02f1f6456315c45c13941f19aa5ed8daba57c/Classes/Invoice.php#L339-L344 |
cvuorinen/phpdoc-markdown-public | src/Extension/TwigClassPublicMethods.php | TwigClassPublicMethods.getPublicMethods | public function getPublicMethods($class)
{
if (!$class instanceof ClassDescriptor) {
return [];
}
$methods = $class->getMagicMethods()
->merge($class->getInheritedMethods())
->merge($class->getMethods());
return array_filter(
$methods->getAll(),
function (MethodDescriptor $method) {
return $method->getVisibility() === 'public';
}
);
} | php | public function getPublicMethods($class)
{
if (!$class instanceof ClassDescriptor) {
return [];
}
$methods = $class->getMagicMethods()
->merge($class->getInheritedMethods())
->merge($class->getMethods());
return array_filter(
$methods->getAll(),
function (MethodDescriptor $method) {
return $method->getVisibility() === 'public';
}
);
} | [
"public",
"function",
"getPublicMethods",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"$",
"class",
"instanceof",
"ClassDescriptor",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"methods",
"=",
"$",
"class",
"->",
"getMagicMethods",
"(",
")",
"->",
"m... | @param ClassDescriptor $class
@return MethodDescriptor[] | [
"@param",
"ClassDescriptor",
"$class"
] | train | https://github.com/cvuorinen/phpdoc-markdown-public/blob/c6751725aa8a26514992080f25d024c06beab71a/src/Extension/TwigClassPublicMethods.php#L44-L60 |
cvuorinen/phpdoc-markdown-public | src/Extension/TwigMarkdownAnchorLink.php | TwigMarkdownAnchorLink.createAnchorLink | public function createAnchorLink($title)
{
$anchor = strtolower($title);
// Check if we already have link to an anchor with the same name, and add count suffix
$linkCounts = array_count_values(self::$links);
$anchorSuffix = array_key_exists($anchor, $linkCounts)
? '-' . $linkCounts[$anchor] : '';
array_push(self::$links, $anchor);
return sprintf("[%s](%s)", $title, '#' . $anchor . $anchorSuffix);
} | php | public function createAnchorLink($title)
{
$anchor = strtolower($title);
// Check if we already have link to an anchor with the same name, and add count suffix
$linkCounts = array_count_values(self::$links);
$anchorSuffix = array_key_exists($anchor, $linkCounts)
? '-' . $linkCounts[$anchor] : '';
array_push(self::$links, $anchor);
return sprintf("[%s](%s)", $title, '#' . $anchor . $anchorSuffix);
} | [
"public",
"function",
"createAnchorLink",
"(",
"$",
"title",
")",
"{",
"$",
"anchor",
"=",
"strtolower",
"(",
"$",
"title",
")",
";",
"// Check if we already have link to an anchor with the same name, and add count suffix",
"$",
"linkCounts",
"=",
"array_count_values",
"(... | @param string $title
@return string | [
"@param",
"string",
"$title"
] | train | https://github.com/cvuorinen/phpdoc-markdown-public/blob/c6751725aa8a26514992080f25d024c06beab71a/src/Extension/TwigMarkdownAnchorLink.php#L52-L63 |
kelunik/acme-client | src/Commands/Auto.php | Auto.checkAndIssue | private function checkAndIssue(array $certificate, string $server, string $storage, int $concurrency = null): \Generator {
$domainPathMap = $this->toDomainPathMap($certificate['paths']);
$domains = \array_keys($domainPathMap);
$commonName = \reset($domains);
$processArgs = [
PHP_BINARY,
$GLOBALS['argv'][0],
'check',
'--server',
$server,
'--storage',
$storage,
'--name',
$commonName,
'--names',
\implode(',', $domains),
];
if ($certificate['rekey'] ?? false) {
$processArgs[] = '--rekey';
}
$process = new Process($processArgs);
$process->start();
$exit = yield $process->join();
if ($exit === 0) {
// No need for renewal
return self::STATUS_NO_CHANGE;
}
if ($exit === 1) {
// Renew certificate
$args = [
PHP_BINARY,
$GLOBALS['argv'][0],
'issue',
'--server',
$server,
'--storage',
$storage,
'--domains',
\implode(',', $domains),
'--path',
\implode(PATH_SEPARATOR, \array_values($domainPathMap)),
];
if (isset($certificate['user'])) {
$args[] = '--user';
$args[] = $certificate['user'];
}
if (isset($certificate['bits'])) {
$args[] = '--bits';
$args[] = $certificate['bits'];
}
if ($concurrency) {
$args[] = '--challenge-concurrency';
$args[] = $concurrency;
}
$process = new Process($args);
$process->start();
$exit = yield $process->join();
if ($exit !== 0) {
// TODO: Print STDOUT and STDERR to file
throw new AcmeException("Unexpected exit code ({$exit}) for '{$process->getCommand()}'.");
}
return self::STATUS_RENEWED;
}
// TODO: Print STDOUT and STDERR to file
throw new AcmeException("Unexpected exit code ({$exit}) for '{$process->getCommand()}'.");
} | php | private function checkAndIssue(array $certificate, string $server, string $storage, int $concurrency = null): \Generator {
$domainPathMap = $this->toDomainPathMap($certificate['paths']);
$domains = \array_keys($domainPathMap);
$commonName = \reset($domains);
$processArgs = [
PHP_BINARY,
$GLOBALS['argv'][0],
'check',
'--server',
$server,
'--storage',
$storage,
'--name',
$commonName,
'--names',
\implode(',', $domains),
];
if ($certificate['rekey'] ?? false) {
$processArgs[] = '--rekey';
}
$process = new Process($processArgs);
$process->start();
$exit = yield $process->join();
if ($exit === 0) {
// No need for renewal
return self::STATUS_NO_CHANGE;
}
if ($exit === 1) {
// Renew certificate
$args = [
PHP_BINARY,
$GLOBALS['argv'][0],
'issue',
'--server',
$server,
'--storage',
$storage,
'--domains',
\implode(',', $domains),
'--path',
\implode(PATH_SEPARATOR, \array_values($domainPathMap)),
];
if (isset($certificate['user'])) {
$args[] = '--user';
$args[] = $certificate['user'];
}
if (isset($certificate['bits'])) {
$args[] = '--bits';
$args[] = $certificate['bits'];
}
if ($concurrency) {
$args[] = '--challenge-concurrency';
$args[] = $concurrency;
}
$process = new Process($args);
$process->start();
$exit = yield $process->join();
if ($exit !== 0) {
// TODO: Print STDOUT and STDERR to file
throw new AcmeException("Unexpected exit code ({$exit}) for '{$process->getCommand()}'.");
}
return self::STATUS_RENEWED;
}
// TODO: Print STDOUT and STDERR to file
throw new AcmeException("Unexpected exit code ({$exit}) for '{$process->getCommand()}'.");
} | [
"private",
"function",
"checkAndIssue",
"(",
"array",
"$",
"certificate",
",",
"string",
"$",
"server",
",",
"string",
"$",
"storage",
",",
"int",
"$",
"concurrency",
"=",
"null",
")",
":",
"\\",
"Generator",
"{",
"$",
"domainPathMap",
"=",
"$",
"this",
... | @param array $certificate certificate configuration
@param string $server server to use for issuance
@param string $storage storage directory
@param int|null $concurrency concurrent challenges
@return \Generator
@throws AcmeException if something does wrong
@throws \Throwable | [
"@param",
"array",
"$certificate",
"certificate",
"configuration",
"@param",
"string",
"$server",
"server",
"to",
"use",
"for",
"issuance",
"@param",
"string",
"$storage",
"storage",
"directory",
"@param",
"int|null",
"$concurrency",
"concurrent",
"challenges"
] | train | https://github.com/kelunik/acme-client/blob/5b112cba3e163185ab93f549a14230a661e8ab36/src/Commands/Auto.php#L185-L262 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV3.php | NoCaptchaV3.getScriptSrc | private function getScriptSrc($callbackName = null)
{
$queries = [];
if ($this->hasLang())
Arr::set($queries, 'hl', $this->lang);
Arr::set($queries, 'render', $this->getSiteKey());
if ($this->hasCallbackName($callbackName))
Arr::set($queries, 'onload', $callbackName);
return $this->getClientUrl() . (count($queries) ? '?' . http_build_query($queries) : '');
} | php | private function getScriptSrc($callbackName = null)
{
$queries = [];
if ($this->hasLang())
Arr::set($queries, 'hl', $this->lang);
Arr::set($queries, 'render', $this->getSiteKey());
if ($this->hasCallbackName($callbackName))
Arr::set($queries, 'onload', $callbackName);
return $this->getClientUrl() . (count($queries) ? '?' . http_build_query($queries) : '');
} | [
"private",
"function",
"getScriptSrc",
"(",
"$",
"callbackName",
"=",
"null",
")",
"{",
"$",
"queries",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasLang",
"(",
")",
")",
"Arr",
"::",
"set",
"(",
"$",
"queries",
",",
"'hl'",
",",
"$",
"t... | Get script source link.
@param string|null $callbackName
@return string | [
"Get",
"script",
"source",
"link",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV3.php#L123-L136 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.display | public function display($name = null, array $attributes = [])
{
return Div::make()->attributes(array_merge(
static::prepareNameAttribute($name),
$this->prepareAttributes($attributes)
));
} | php | public function display($name = null, array $attributes = [])
{
return Div::make()->attributes(array_merge(
static::prepareNameAttribute($name),
$this->prepareAttributes($attributes)
));
} | [
"public",
"function",
"display",
"(",
"$",
"name",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"return",
"Div",
"::",
"make",
"(",
")",
"->",
"attributes",
"(",
"array_merge",
"(",
"static",
"::",
"prepareNameAttribute",
"(",
... | Display Captcha.
@param string|null $name
@param array $attributes
@return \Arcanedev\Html\Elements\Div | [
"Display",
"Captcha",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L69-L75 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.button | public function button($value, array $attributes = [])
{
return Button::make()->text($value)->attributes(array_merge(
['data-callback' => 'onSubmit'],
$this->prepareAttributes($attributes)
));
} | php | public function button($value, array $attributes = [])
{
return Button::make()->text($value)->attributes(array_merge(
['data-callback' => 'onSubmit'],
$this->prepareAttributes($attributes)
));
} | [
"public",
"function",
"button",
"(",
"$",
"value",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"return",
"Button",
"::",
"make",
"(",
")",
"->",
"text",
"(",
"$",
"value",
")",
"->",
"attributes",
"(",
"array_merge",
"(",
"[",
"'data-ca... | Display an invisible Captcha (bind the challenge to a button).
@param string $value
@param array $attributes
@return \Arcanedev\Html\Elements\Button | [
"Display",
"an",
"invisible",
"Captcha",
"(",
"bind",
"the",
"challenge",
"to",
"a",
"button",
")",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L117-L123 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.scriptWithCallback | public function scriptWithCallback(array $captchas, $callbackName = 'captchaRenderCallback')
{
$script = $this->script($callbackName)->toHtml();
if ( ! empty($script) && ! empty($captchas)) {
$script = implode(PHP_EOL, [
$this->getApiScript()->toHtml(),
'<script>',
"var $callbackName = function() {",
$this->renderCaptchas($captchas),
'};',
'</script>',
$script,
]);
}
return $this->toHtmlString($script);
} | php | public function scriptWithCallback(array $captchas, $callbackName = 'captchaRenderCallback')
{
$script = $this->script($callbackName)->toHtml();
if ( ! empty($script) && ! empty($captchas)) {
$script = implode(PHP_EOL, [
$this->getApiScript()->toHtml(),
'<script>',
"var $callbackName = function() {",
$this->renderCaptchas($captchas),
'};',
'</script>',
$script,
]);
}
return $this->toHtmlString($script);
} | [
"public",
"function",
"scriptWithCallback",
"(",
"array",
"$",
"captchas",
",",
"$",
"callbackName",
"=",
"'captchaRenderCallback'",
")",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"script",
"(",
"$",
"callbackName",
")",
"->",
"toHtml",
"(",
")",
";",
"i... | Get script tag with a callback function.
@param array $captchas
@param string $callbackName
@return \Illuminate\Support\HtmlString | [
"Get",
"script",
"tag",
"with",
"a",
"callback",
"function",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L200-L217 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.prepareAttributes | private function prepareAttributes(array $attributes)
{
$attributes = array_merge(
['class' => 'g-recaptcha', 'data-sitekey' => $this->siteKey],
array_filter($attributes)
);
self::checkDataAttribute($attributes, 'data-type', ['image', 'audio'], 'image');
self::checkDataAttribute($attributes, 'data-theme', ['light', 'dark'], 'light');
self::checkDataAttribute($attributes, 'data-size', ['normal', 'compact', 'invisible'], 'normal');
self::checkDataAttribute($attributes, 'data-badge', ['bottomright', 'bottomleft', 'inline'], 'bottomright');
return $attributes;
} | php | private function prepareAttributes(array $attributes)
{
$attributes = array_merge(
['class' => 'g-recaptcha', 'data-sitekey' => $this->siteKey],
array_filter($attributes)
);
self::checkDataAttribute($attributes, 'data-type', ['image', 'audio'], 'image');
self::checkDataAttribute($attributes, 'data-theme', ['light', 'dark'], 'light');
self::checkDataAttribute($attributes, 'data-size', ['normal', 'compact', 'invisible'], 'normal');
self::checkDataAttribute($attributes, 'data-badge', ['bottomright', 'bottomleft', 'inline'], 'bottomright');
return $attributes;
} | [
"private",
"function",
"prepareAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"=",
"array_merge",
"(",
"[",
"'class'",
"=>",
"'g-recaptcha'",
",",
"'data-sitekey'",
"=>",
"$",
"this",
"->",
"siteKey",
"]",
",",
"array_filter",
"(",
... | Prepare the attributes.
@param array $attributes
@return array | [
"Prepare",
"the",
"attributes",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L274-L287 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.checkDataAttribute | private static function checkDataAttribute(array &$attributes, $name, array $supported, $default)
{
$attribute = $attributes[$name] ?? null;
if ( ! is_null($attribute)) {
$attribute = (is_string($attribute) && in_array($attribute, $supported))
? strtolower(trim($attribute))
: $default;
$attributes[$name] = $attribute;
}
} | php | private static function checkDataAttribute(array &$attributes, $name, array $supported, $default)
{
$attribute = $attributes[$name] ?? null;
if ( ! is_null($attribute)) {
$attribute = (is_string($attribute) && in_array($attribute, $supported))
? strtolower(trim($attribute))
: $default;
$attributes[$name] = $attribute;
}
} | [
"private",
"static",
"function",
"checkDataAttribute",
"(",
"array",
"&",
"$",
"attributes",
",",
"$",
"name",
",",
"array",
"$",
"supported",
",",
"$",
"default",
")",
"{",
"$",
"attribute",
"=",
"$",
"attributes",
"[",
"$",
"name",
"]",
"??",
"null",
... | Check the `data-*` attribute.
@param array $attributes
@param string $name
@param array $supported
@param string $default | [
"Check",
"the",
"data",
"-",
"*",
"attribute",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L297-L308 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaV2.php | NoCaptchaV2.prepareNameAttribute | protected static function prepareNameAttribute($name)
{
if (is_null($name))
return [];
if ($name === AbstractNoCaptcha::CAPTCHA_NAME) {
throw new InvalidArgumentException(
'The captcha name must be different from "' . AbstractNoCaptcha::CAPTCHA_NAME . '".'
);
}
return array_combine(['id', 'name'], [$name, $name]);
} | php | protected static function prepareNameAttribute($name)
{
if (is_null($name))
return [];
if ($name === AbstractNoCaptcha::CAPTCHA_NAME) {
throw new InvalidArgumentException(
'The captcha name must be different from "' . AbstractNoCaptcha::CAPTCHA_NAME . '".'
);
}
return array_combine(['id', 'name'], [$name, $name]);
} | [
"protected",
"static",
"function",
"prepareNameAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"return",
"[",
"]",
";",
"if",
"(",
"$",
"name",
"===",
"AbstractNoCaptcha",
"::",
"CAPTCHA_NAME",
")",
"{",
"throw",... | Prepare the name and id attributes.
@param string|null $name
@return array
@throws \Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException | [
"Prepare",
"the",
"name",
"and",
"id",
"attributes",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaV2.php#L319-L331 |
ARCANEDEV/noCAPTCHA | src/Utilities/AbstractResponse.php | AbstractResponse.fromJson | public static function fromJson($json)
{
$responseData = json_decode($json, true);
if ( ! $responseData)
return new static(false, [ResponseV3::E_INVALID_JSON]);
return static::fromArray($responseData);
} | php | public static function fromJson($json)
{
$responseData = json_decode($json, true);
if ( ! $responseData)
return new static(false, [ResponseV3::E_INVALID_JSON]);
return static::fromArray($responseData);
} | [
"public",
"static",
"function",
"fromJson",
"(",
"$",
"json",
")",
"{",
"$",
"responseData",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"responseData",
")",
"return",
"new",
"static",
"(",
"false",
",",
"[",
"Re... | Build the response from the expected JSON returned by the service.
@param string $json
@return \Arcanedev\NoCaptcha\Utilities\AbstractResponse | [
"Build",
"the",
"response",
"from",
"the",
"expected",
"JSON",
"returned",
"by",
"the",
"service",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/AbstractResponse.php#L151-L159 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaServiceProvider.php | NoCaptchaServiceProvider.registerNoCaptchaManager | private function registerNoCaptchaManager()
{
$this->singleton(Contracts\NoCaptchaManager::class, function ($app) {
return new NoCaptchaManager($app);
});
$this->bind(Contracts\NoCaptcha::class, function (Application $app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return $app->make(Contracts\NoCaptchaManager::class)->version(
$config->get('no-captcha.version')
);
});
} | php | private function registerNoCaptchaManager()
{
$this->singleton(Contracts\NoCaptchaManager::class, function ($app) {
return new NoCaptchaManager($app);
});
$this->bind(Contracts\NoCaptcha::class, function (Application $app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return $app->make(Contracts\NoCaptchaManager::class)->version(
$config->get('no-captcha.version')
);
});
} | [
"private",
"function",
"registerNoCaptchaManager",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"NoCaptchaManager",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"NoCaptchaManager",
"(",
"$",
"app",
")"... | /* -----------------------------------------------------------------
| Other Methods
| ----------------------------------------------------------------- | [
"/",
"*",
"-----------------------------------------------------------------",
"|",
"Other",
"Methods",
"|",
"-----------------------------------------------------------------"
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaServiceProvider.php#L71-L85 |
ARCANEDEV/noCAPTCHA | src/NoCaptchaServiceProvider.php | NoCaptchaServiceProvider.registerFormMacros | private function registerFormMacros($app)
{
foreach ([FormBuilder::class, 'form'] as $alias) {
if ($app->bound($alias)) {
$app[$alias]->macro('captcha', function($name = null) use ($app) {
return $app[Contracts\NoCaptcha::class]->input($name);
});
}
}
} | php | private function registerFormMacros($app)
{
foreach ([FormBuilder::class, 'form'] as $alias) {
if ($app->bound($alias)) {
$app[$alias]->macro('captcha', function($name = null) use ($app) {
return $app[Contracts\NoCaptcha::class]->input($name);
});
}
}
} | [
"private",
"function",
"registerFormMacros",
"(",
"$",
"app",
")",
"{",
"foreach",
"(",
"[",
"FormBuilder",
"::",
"class",
",",
"'form'",
"]",
"as",
"$",
"alias",
")",
"{",
"if",
"(",
"$",
"app",
"->",
"bound",
"(",
"$",
"alias",
")",
")",
"{",
"$"... | Register Form Macros.
@param \Illuminate\Contracts\Foundation\Application $app | [
"Register",
"Form",
"Macros",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/NoCaptchaServiceProvider.php#L92-L101 |
ARCANEDEV/noCAPTCHA | src/Rules/CaptchaRule.php | CaptchaRule.passes | public function passes($attribute, $value)
{
$ip = request()->ip();
if (in_array($ip, $this->skipIps))
return true;
return no_captcha($this->version)
->verify($value, $ip)
->isSuccess();
} | php | public function passes($attribute, $value)
{
$ip = request()->ip();
if (in_array($ip, $this->skipIps))
return true;
return no_captcha($this->version)
->verify($value, $ip)
->isSuccess();
} | [
"public",
"function",
"passes",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"ip",
"=",
"request",
"(",
")",
"->",
"ip",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"ip",
",",
"$",
"this",
"->",
"skipIps",
")",
")",
"return",
"t... | Determine if the validation rule passes.
@param string $attribute
@param mixed $value
@return bool | [
"Determine",
"if",
"the",
"validation",
"rule",
"passes",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Rules/CaptchaRule.php#L89-L99 |
ARCANEDEV/noCAPTCHA | src/AbstractNoCaptcha.php | AbstractNoCaptcha.verify | public function verify($response, $clientIp = null)
{
return $this->response = $this->sendVerifyRequest([
'secret' => $this->secret,
'response' => $response,
'remoteip' => $clientIp
]);
} | php | public function verify($response, $clientIp = null)
{
return $this->response = $this->sendVerifyRequest([
'secret' => $this->secret,
'response' => $response,
'remoteip' => $clientIp
]);
} | [
"public",
"function",
"verify",
"(",
"$",
"response",
",",
"$",
"clientIp",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"sendVerifyRequest",
"(",
"[",
"'secret'",
"=>",
"$",
"this",
"->",
"secret",
",",
"'res... | Verify Response.
@param string $response
@param string $clientIp
@return \Arcanedev\NoCaptcha\Utilities\AbstractResponse|mixed | [
"Verify",
"Response",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/AbstractNoCaptcha.php#L213-L220 |
ARCANEDEV/noCAPTCHA | src/AbstractNoCaptcha.php | AbstractNoCaptcha.verifyRequest | public function verifyRequest(ServerRequestInterface $request)
{
$body = $request->getParsedBody();
$server = $request->getServerParams();
return $this->verify(
$body[self::CAPTCHA_NAME] ?? '',
$server['REMOTE_ADDR'] ?? null
);
} | php | public function verifyRequest(ServerRequestInterface $request)
{
$body = $request->getParsedBody();
$server = $request->getServerParams();
return $this->verify(
$body[self::CAPTCHA_NAME] ?? '',
$server['REMOTE_ADDR'] ?? null
);
} | [
"public",
"function",
"verifyRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"body",
"=",
"$",
"request",
"->",
"getParsedBody",
"(",
")",
";",
"$",
"server",
"=",
"$",
"request",
"->",
"getServerParams",
"(",
")",
";",
"return",
"$... | Calls the reCAPTCHA siteverify API to verify whether the user passes CAPTCHA
test using a PSR-7 ServerRequest object.
@param \Psr\Http\Message\ServerRequestInterface $request
@return \Arcanedev\NoCaptcha\Utilities\AbstractResponse | [
"Calls",
"the",
"reCAPTCHA",
"siteverify",
"API",
"to",
"verify",
"whether",
"the",
"user",
"passes",
"CAPTCHA",
"test",
"using",
"a",
"PSR",
"-",
"7",
"ServerRequest",
"object",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/AbstractNoCaptcha.php#L230-L239 |
ARCANEDEV/noCAPTCHA | src/AbstractNoCaptcha.php | AbstractNoCaptcha.sendVerifyRequest | protected function sendVerifyRequest(array $query = [])
{
$query = array_filter($query);
$json = $this->request->send(
$this->getVerificationUrl().'?'.http_build_query($query)
);
return $this->parseResponse($json);
} | php | protected function sendVerifyRequest(array $query = [])
{
$query = array_filter($query);
$json = $this->request->send(
$this->getVerificationUrl().'?'.http_build_query($query)
);
return $this->parseResponse($json);
} | [
"protected",
"function",
"sendVerifyRequest",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"array_filter",
"(",
"$",
"query",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"request",
"->",
"send",
"(",
"$",
"this",
"->",
... | Send verify request to API and get response.
@param array $query
@return \Arcanedev\NoCaptcha\Utilities\ResponseV3 | [
"Send",
"verify",
"request",
"to",
"API",
"and",
"get",
"response",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/AbstractNoCaptcha.php#L248-L256 |
ARCANEDEV/noCAPTCHA | src/AbstractNoCaptcha.php | AbstractNoCaptcha.checkKey | private static function checkKey($name, &$value)
{
self::checkIsString($name, $value);
$value = trim($value);
self::checkIsNotEmpty($name, $value);
} | php | private static function checkKey($name, &$value)
{
self::checkIsString($name, $value);
$value = trim($value);
self::checkIsNotEmpty($name, $value);
} | [
"private",
"static",
"function",
"checkKey",
"(",
"$",
"name",
",",
"&",
"$",
"value",
")",
"{",
"self",
"::",
"checkIsString",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"self",
"::",
"... | Check key.
@param string $name
@param string $value | [
"Check",
"key",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/AbstractNoCaptcha.php#L288-L295 |
ARCANEDEV/noCAPTCHA | src/Utilities/ResponseV2.php | ResponseV2.fromArray | public static function fromArray(array $array)
{
$hostname = $array['hostname'] ?? null;
$challengeTs = $array['challenge_ts'] ?? null;
$apkPackageName = $array['apk_package_name'] ?? null;
if (isset($array['success']) && $array['success'] == true)
return new static(true, [], $hostname, $challengeTs, $apkPackageName);
if ( ! (isset($array['error-codes']) && is_array($array['error-codes'])))
$array['error-codes'] = [ResponseV3::E_UNKNOWN_ERROR];
return new static(false, $array['error-codes'], $hostname, $challengeTs, $apkPackageName);
} | php | public static function fromArray(array $array)
{
$hostname = $array['hostname'] ?? null;
$challengeTs = $array['challenge_ts'] ?? null;
$apkPackageName = $array['apk_package_name'] ?? null;
if (isset($array['success']) && $array['success'] == true)
return new static(true, [], $hostname, $challengeTs, $apkPackageName);
if ( ! (isset($array['error-codes']) && is_array($array['error-codes'])))
$array['error-codes'] = [ResponseV3::E_UNKNOWN_ERROR];
return new static(false, $array['error-codes'], $hostname, $challengeTs, $apkPackageName);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"hostname",
"=",
"$",
"array",
"[",
"'hostname'",
"]",
"??",
"null",
";",
"$",
"challengeTs",
"=",
"$",
"array",
"[",
"'challenge_ts'",
"]",
"??",
"null",
";",
"$",... | Build the response from an array.
@param array $array
@return \Arcanedev\NoCaptcha\Utilities\ResponseV2 | [
"Build",
"the",
"response",
"from",
"an",
"array",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/ResponseV2.php#L23-L36 |
ARCANEDEV/noCAPTCHA | src/Utilities/ResponseV2.php | ResponseV2.toArray | public function toArray()
{
return [
'success' => $this->isSuccess(),
'hostname' => $this->getHostname(),
'challenge_ts' => $this->getChallengeTs(),
'apk_package_name' => $this->getApkPackageName(),
'error-codes' => $this->getErrorCodes(),
];
} | php | public function toArray()
{
return [
'success' => $this->isSuccess(),
'hostname' => $this->getHostname(),
'challenge_ts' => $this->getChallengeTs(),
'apk_package_name' => $this->getApkPackageName(),
'error-codes' => $this->getErrorCodes(),
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'success'",
"=>",
"$",
"this",
"->",
"isSuccess",
"(",
")",
",",
"'hostname'",
"=>",
"$",
"this",
"->",
"getHostname",
"(",
")",
",",
"'challenge_ts'",
"=>",
"$",
"this",
"->",
"getChallenge... | Convert the response object to array.
@return array | [
"Convert",
"the",
"response",
"object",
"to",
"array",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/ResponseV2.php#L43-L52 |
ARCANEDEV/noCAPTCHA | src/Utilities/Request.php | Request.curl | protected function curl()
{
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
]);
$result = curl_exec($curl);
curl_close($curl);
return $result;
} | php | protected function curl()
{
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
]);
$result = curl_exec($curl);
curl_close($curl);
return $result;
} | [
"protected",
"function",
"curl",
"(",
")",
"{",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"[",
"CURLOPT_URL",
"=>",
"$",
"this",
"->",
"url",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_SSL_VER... | Create an api request using curl.
@return string | [
"Create",
"an",
"api",
"request",
"using",
"curl",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/Request.php#L57-L69 |
ARCANEDEV/noCAPTCHA | src/Utilities/Request.php | Request.send | public function send($url, $curled = true)
{
$this->setUrl($url);
$result = ($this->isCurlExists() && $curled === true)
? $this->curl()
: file_get_contents($this->url);
return $this->checkResult($result) ? $result : '{}';
} | php | public function send($url, $curled = true)
{
$this->setUrl($url);
$result = ($this->isCurlExists() && $curled === true)
? $this->curl()
: file_get_contents($this->url);
return $this->checkResult($result) ? $result : '{}';
} | [
"public",
"function",
"send",
"(",
"$",
"url",
",",
"$",
"curled",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"setUrl",
"(",
"$",
"url",
")",
";",
"$",
"result",
"=",
"(",
"$",
"this",
"->",
"isCurlExists",
"(",
")",
"&&",
"$",
"curled",
"===",
... | Run the request and get response.
@param string $url
@param bool $curled
@return string | [
"Run",
"the",
"request",
"and",
"get",
"response",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/Request.php#L79-L88 |
ARCANEDEV/noCAPTCHA | src/Utilities/ResponseV3.php | ResponseV3.fromArray | public static function fromArray(array $array)
{
$hostname = $array['hostname'] ?? null;
$challengeTs = $array['challenge_ts'] ?? null;
$apkPackageName = $array['apk_package_name'] ?? null;
$score = isset($array['score']) ? floatval($array['score']) : null;
$action = $array['action'] ?? null;
if (isset($array['success']) && $array['success'] == true)
return new static(true, [], $hostname, $challengeTs, $apkPackageName, $score, $action);
if ( ! (isset($array['error-codes']) && is_array($array['error-codes'])))
$array['error-codes'] = [ResponseV3::E_UNKNOWN_ERROR];
return new static(false, $array['error-codes'], $hostname, $challengeTs, $apkPackageName, $score, $action);
} | php | public static function fromArray(array $array)
{
$hostname = $array['hostname'] ?? null;
$challengeTs = $array['challenge_ts'] ?? null;
$apkPackageName = $array['apk_package_name'] ?? null;
$score = isset($array['score']) ? floatval($array['score']) : null;
$action = $array['action'] ?? null;
if (isset($array['success']) && $array['success'] == true)
return new static(true, [], $hostname, $challengeTs, $apkPackageName, $score, $action);
if ( ! (isset($array['error-codes']) && is_array($array['error-codes'])))
$array['error-codes'] = [ResponseV3::E_UNKNOWN_ERROR];
return new static(false, $array['error-codes'], $hostname, $challengeTs, $apkPackageName, $score, $action);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"hostname",
"=",
"$",
"array",
"[",
"'hostname'",
"]",
"??",
"null",
";",
"$",
"challengeTs",
"=",
"$",
"array",
"[",
"'challenge_ts'",
"]",
"??",
"null",
";",
"$",... | Build the response from an array.
@param array $array
@return \Arcanedev\NoCaptcha\Utilities\ResponseV3 | [
"Build",
"the",
"response",
"from",
"an",
"array",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/ResponseV3.php#L138-L153 |
ARCANEDEV/noCAPTCHA | src/Utilities/ResponseV3.php | ResponseV3.toArray | public function toArray()
{
return [
'success' => $this->isSuccess(),
'hostname' => $this->getHostname(),
'challenge_ts' => $this->getChallengeTs(),
'apk_package_name' => $this->getApkPackageName(),
'score' => $this->getScore(),
'action' => $this->getAction(),
'error-codes' => $this->getErrorCodes(),
];
} | php | public function toArray()
{
return [
'success' => $this->isSuccess(),
'hostname' => $this->getHostname(),
'challenge_ts' => $this->getChallengeTs(),
'apk_package_name' => $this->getApkPackageName(),
'score' => $this->getScore(),
'action' => $this->getAction(),
'error-codes' => $this->getErrorCodes(),
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'success'",
"=>",
"$",
"this",
"->",
"isSuccess",
"(",
")",
",",
"'hostname'",
"=>",
"$",
"this",
"->",
"getHostname",
"(",
")",
",",
"'challenge_ts'",
"=>",
"$",
"this",
"->",
"getChallenge... | Convert the response object to array.
@return array | [
"Convert",
"the",
"response",
"object",
"to",
"array",
"."
] | train | https://github.com/ARCANEDEV/noCAPTCHA/blob/ec3702eb76cb611340348625e115fc94dad42204/src/Utilities/ResponseV3.php#L160-L171 |
10up/wp-codeception | classes/WPCC/Subscriber/Bootstrap.php | Bootstrap.loadBootstrap | public function loadBootstrap( SuiteEvent $e ) {
$settings = $e->getSettings();
if ( ! isset( $settings['bootstrap'] ) || ! filter_var( $settings['bootstrap'], FILTER_VALIDATE_BOOLEAN ) ) {
return;
}
$bootstrap = $settings['path'] . $settings['bootstrap'];
if ( ! is_file( $bootstrap ) ) {
throw new ConfigurationException( "Bootstrap file {$bootstrap} can't be loaded" );
}
require_once $bootstrap;
} | php | public function loadBootstrap( SuiteEvent $e ) {
$settings = $e->getSettings();
if ( ! isset( $settings['bootstrap'] ) || ! filter_var( $settings['bootstrap'], FILTER_VALIDATE_BOOLEAN ) ) {
return;
}
$bootstrap = $settings['path'] . $settings['bootstrap'];
if ( ! is_file( $bootstrap ) ) {
throw new ConfigurationException( "Bootstrap file {$bootstrap} can't be loaded" );
}
require_once $bootstrap;
} | [
"public",
"function",
"loadBootstrap",
"(",
"SuiteEvent",
"$",
"e",
")",
"{",
"$",
"settings",
"=",
"$",
"e",
"->",
"getSettings",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"settings",
"[",
"'bootstrap'",
"]",
")",
"||",
"!",
"filter_var",
"(... | Loads bootstrap file on \Codeception\Events::SUITE_BEFORE event.
@since 1.0.1
@throws \Codeception\Exception\Configuration if a bootstrap file hasn't been found.
@access public
@param \Codeception\Event\SuiteEvent $e The event object. | [
"Loads",
"bootstrap",
"file",
"on",
"\\",
"Codeception",
"\\",
"Events",
"::",
"SUITE_BEFORE",
"event",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Subscriber/Bootstrap.php#L44-L56 |
10up/wp-codeception | classes/WPCC/Module/WordPress.php | WordPress.seeUserMetaFor | public function seeUserMetaFor( $user_id, $meta_key, $meta_value = null ) {
$metas = get_user_meta( $user_id, $meta_key );
$message = sprintf( 'User meta %s does not exist', $meta_key );
$this->assertNotEmpty( $metas, $message );
if ( func_num_args() > 2 ) {
$message = sprintf( 'User meta %s does not contain expected value', $meta_key );
$this->assertContains( $meta_value, $metas, $message );
}
} | php | public function seeUserMetaFor( $user_id, $meta_key, $meta_value = null ) {
$metas = get_user_meta( $user_id, $meta_key );
$message = sprintf( 'User meta %s does not exist', $meta_key );
$this->assertNotEmpty( $metas, $message );
if ( func_num_args() > 2 ) {
$message = sprintf( 'User meta %s does not contain expected value', $meta_key );
$this->assertContains( $meta_value, $metas, $message );
}
} | [
"public",
"function",
"seeUserMetaFor",
"(",
"$",
"user_id",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
"=",
"null",
")",
"{",
"$",
"metas",
"=",
"get_user_meta",
"(",
"$",
"user_id",
",",
"$",
"meta_key",
")",
";",
"$",
"message",
"=",
"sprintf",
"... | Checks user meta exists for an user.
@since 1.0.0
@access public
@param int $user_id The user id.
@param string $meta_key The meta key to check.
@param mixed $meta_value The meta value to check | [
"Checks",
"user",
"meta",
"exists",
"for",
"an",
"user",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WordPress.php#L43-L53 |
10up/wp-codeception | classes/WPCC/Module/WordPress.php | WordPress.dontSeeUserMetaFor | public function dontSeeUserMetaFor( $user_id, $meta_key, $meta_value = null ) {
$metas = get_user_meta( $user_id, $meta_key );
if ( func_num_args() > 2 ) {
$message = sprintf( 'User meta %s contains not expected value', $meta_key );
$this->assertNotContains( $meta_value, $metas, $message );
} else {
$message = sprintf( 'User meta %s is not empty', $meta_key );
$this->assertEmpty( $metas, $message );
}
} | php | public function dontSeeUserMetaFor( $user_id, $meta_key, $meta_value = null ) {
$metas = get_user_meta( $user_id, $meta_key );
if ( func_num_args() > 2 ) {
$message = sprintf( 'User meta %s contains not expected value', $meta_key );
$this->assertNotContains( $meta_value, $metas, $message );
} else {
$message = sprintf( 'User meta %s is not empty', $meta_key );
$this->assertEmpty( $metas, $message );
}
} | [
"public",
"function",
"dontSeeUserMetaFor",
"(",
"$",
"user_id",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
"=",
"null",
")",
"{",
"$",
"metas",
"=",
"get_user_meta",
"(",
"$",
"user_id",
",",
"$",
"meta_key",
")",
";",
"if",
"(",
"func_num_args",
"("... | Checks if user meta doesn't exists.
@since 1.0.0
@access public
@param int $user_id The user id.
@param string $meta_key The meta key to check.
@param mixed $meta_value The meta value to check | [
"Checks",
"if",
"user",
"meta",
"doesn",
"t",
"exists",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WordPress.php#L65-L75 |
10up/wp-codeception | classes/WPCC/Module/WordPress.php | WordPress.seePostMetaFor | public function seePostMetaFor( $post_id, $meta_key, $meta_value = null ) {
$metas = get_post_meta( $post_id, $meta_key );
$message = sprintf( 'Post meta %s does not exist', $meta_key );
$this->assertNotEmpty( $metas, $message );
if ( func_num_args() > 2 ) {
$message = sprintf( 'Post meta %s does not contain expected value', $meta_key );
$this->assertContains( $meta_value, $metas, $message );
}
} | php | public function seePostMetaFor( $post_id, $meta_key, $meta_value = null ) {
$metas = get_post_meta( $post_id, $meta_key );
$message = sprintf( 'Post meta %s does not exist', $meta_key );
$this->assertNotEmpty( $metas, $message );
if ( func_num_args() > 2 ) {
$message = sprintf( 'Post meta %s does not contain expected value', $meta_key );
$this->assertContains( $meta_value, $metas, $message );
}
} | [
"public",
"function",
"seePostMetaFor",
"(",
"$",
"post_id",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
"=",
"null",
")",
"{",
"$",
"metas",
"=",
"get_post_meta",
"(",
"$",
"post_id",
",",
"$",
"meta_key",
")",
";",
"$",
"message",
"=",
"sprintf",
"... | Checks a post meta exists for a post.
@since 1.0.0
@access public
@param int $post_id The post id.
@param string $meta_key The meta key to check.
@param mixed $meta_value The meta value to check | [
"Checks",
"a",
"post",
"meta",
"exists",
"for",
"a",
"post",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WordPress.php#L87-L97 |
10up/wp-codeception | classes/WPCC/Module/WordPress.php | WordPress.dontSeePostMetaFor | public function dontSeePostMetaFor( $post, $meta_key, $meta_value = null ) {
$metas = get_post_meta( $post, $meta_key );
if ( func_num_args() > 2 ) {
$message = sprintf( 'Post meta %s contains not expected value', $meta_key );
$this->assertNotContains( $meta_value, $metas, $message );
} else {
$message = sprintf( 'Post meta %s is not empty', $meta_key );
$this->assertEmpty( $metas, $message );
}
} | php | public function dontSeePostMetaFor( $post, $meta_key, $meta_value = null ) {
$metas = get_post_meta( $post, $meta_key );
if ( func_num_args() > 2 ) {
$message = sprintf( 'Post meta %s contains not expected value', $meta_key );
$this->assertNotContains( $meta_value, $metas, $message );
} else {
$message = sprintf( 'Post meta %s is not empty', $meta_key );
$this->assertEmpty( $metas, $message );
}
} | [
"public",
"function",
"dontSeePostMetaFor",
"(",
"$",
"post",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
"=",
"null",
")",
"{",
"$",
"metas",
"=",
"get_post_meta",
"(",
"$",
"post",
",",
"$",
"meta_key",
")",
";",
"if",
"(",
"func_num_args",
"(",
")... | Checks if post meta doesn't exists.
@since 1.0.0
@access public
@param int $post The post id.
@param string $meta_key The meta key to check.
@param mixed $meta_value The meta value to check | [
"Checks",
"if",
"post",
"meta",
"doesn",
"t",
"exists",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WordPress.php#L109-L119 |
10up/wp-codeception | classes/WPCC/Component/Factory/Attachment.php | Attachment._createObject | protected function _createObject( $args = array() ) {
if ( empty( $args['post_mime_type'] ) ) {
if ( ! empty( $args['file'] ) && is_readable( $args['file'] ) ) {
$this->_debug( 'Reading mime type of the file: ' . $args['file'] );
$filetype = wp_check_filetype( basename( $args['file'] ), null );
if ( ! empty( $filetype['type'] ) ) {
$args['post_mime_type'] = $filetype['type'];
$this->_debug( 'Mime type found: ' . $filetype['type'] );
} else {
$this->_debug( 'Mime type not found' );
}
}
}
$attachment_id = wp_insert_attachment( $args );
if ( $attachment_id ) {
$this->_debug(
'Generated attachment ID: %d (file: %s)',
$attachment_id,
! empty( $args['file'] ) ? $args['file'] : 'not-provided'
);
$this->_debug( 'Generating attachment metadata' );
$metadata = wp_generate_attachment_metadata( $attachment_id, $args['file'] );
if ( is_wp_error( $metadata ) ) {
$this->_debug(
'Attachment metadata generation failed with error [%s] %s',
$metadata->get_error_code(),
$metadata->get_error_message()
);
} elseif ( empty( $metadata ) ) {
$this->_debug( 'Attachment metadata generation failed' );
} else {
wp_update_attachment_metadata( $attachment_id, $metadata );
}
} else {
$this->_debug( 'Attachment generation failed' );
}
return $attachment_id;
} | php | protected function _createObject( $args = array() ) {
if ( empty( $args['post_mime_type'] ) ) {
if ( ! empty( $args['file'] ) && is_readable( $args['file'] ) ) {
$this->_debug( 'Reading mime type of the file: ' . $args['file'] );
$filetype = wp_check_filetype( basename( $args['file'] ), null );
if ( ! empty( $filetype['type'] ) ) {
$args['post_mime_type'] = $filetype['type'];
$this->_debug( 'Mime type found: ' . $filetype['type'] );
} else {
$this->_debug( 'Mime type not found' );
}
}
}
$attachment_id = wp_insert_attachment( $args );
if ( $attachment_id ) {
$this->_debug(
'Generated attachment ID: %d (file: %s)',
$attachment_id,
! empty( $args['file'] ) ? $args['file'] : 'not-provided'
);
$this->_debug( 'Generating attachment metadata' );
$metadata = wp_generate_attachment_metadata( $attachment_id, $args['file'] );
if ( is_wp_error( $metadata ) ) {
$this->_debug(
'Attachment metadata generation failed with error [%s] %s',
$metadata->get_error_code(),
$metadata->get_error_message()
);
} elseif ( empty( $metadata ) ) {
$this->_debug( 'Attachment metadata generation failed' );
} else {
wp_update_attachment_metadata( $attachment_id, $metadata );
}
} else {
$this->_debug( 'Attachment generation failed' );
}
return $attachment_id;
} | [
"protected",
"function",
"_createObject",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
"[",
"'post_mime_type'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'file'",
"]",
")",
"... | Generates a new attachemnt.
@since 1.0.0
@access protected
@param array $args The array of arguments to use during a new attachment creation.
@return int The newly created attachment's ID on success, otherwise 0. | [
"Generates",
"a",
"new",
"attachemnt",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory/Attachment.php#L42-L83 |
10up/wp-codeception | classes/WPCC/CLI/Selenium.php | Selenium.stop | public function stop( $args, $assoc_args ) {
$selenium = $this->_get_executable();
$pids = trim( shell_exec( "pgrep -l -f {$selenium}" ) );
$pids = explode( PHP_EOL, (string) $pids );
if ( ! empty( $pids ) && count( $pids ) >= 1 ) {
foreach ( $pids as $pid ) {
shell_exec( "kill -15 {$pid} > /dev/null 2>/dev/null" );
}
\WP_CLI::success( 'Selenium server is stopped.' );
} else {
\WP_CLI::warning( 'Selenium server is not started yet.' );
}
} | php | public function stop( $args, $assoc_args ) {
$selenium = $this->_get_executable();
$pids = trim( shell_exec( "pgrep -l -f {$selenium}" ) );
$pids = explode( PHP_EOL, (string) $pids );
if ( ! empty( $pids ) && count( $pids ) >= 1 ) {
foreach ( $pids as $pid ) {
shell_exec( "kill -15 {$pid} > /dev/null 2>/dev/null" );
}
\WP_CLI::success( 'Selenium server is stopped.' );
} else {
\WP_CLI::warning( 'Selenium server is not started yet.' );
}
} | [
"public",
"function",
"stop",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"selenium",
"=",
"$",
"this",
"->",
"_get_executable",
"(",
")",
";",
"$",
"pids",
"=",
"trim",
"(",
"shell_exec",
"(",
"\"pgrep -l -f {$selenium}\"",
")",
")",
";",
... | Stops selenium server.
### OPTIONS
### EXAMPLE
wp selenium stop
@since 1.0.0
@access public
@param array $args Unassociated array of arguments passed to this command.
@param array $assoc_args Associated array of arguments passed to this command. | [
"Stops",
"selenium",
"server",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/CLI/Selenium.php#L64-L77 |
10up/wp-codeception | classes/WPCC/CLI/Selenium.php | Selenium.start | public function start( $args, $assoc_args ) {
$selenium = $this->_get_executable();
if ( is_executable( $selenium ) ) {
$pids = explode( PHP_EOL, trim( shell_exec( "pgrep -f {$selenium}" ) ) );
if ( count( $pids ) < 2 ) {
shell_exec( "{$selenium} > /dev/null 2>/dev/null &" );
\WP_CLI::success( 'Selenium server started.' );
} else {
\WP_CLI::warning( 'Selenium server is already started.' );
}
} else {
\WP_CLI::error( 'Selenium server is not executable or not installed.' );
}
} | php | public function start( $args, $assoc_args ) {
$selenium = $this->_get_executable();
if ( is_executable( $selenium ) ) {
$pids = explode( PHP_EOL, trim( shell_exec( "pgrep -f {$selenium}" ) ) );
if ( count( $pids ) < 2 ) {
shell_exec( "{$selenium} > /dev/null 2>/dev/null &" );
\WP_CLI::success( 'Selenium server started.' );
} else {
\WP_CLI::warning( 'Selenium server is already started.' );
}
} else {
\WP_CLI::error( 'Selenium server is not executable or not installed.' );
}
} | [
"public",
"function",
"start",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"selenium",
"=",
"$",
"this",
"->",
"_get_executable",
"(",
")",
";",
"if",
"(",
"is_executable",
"(",
"$",
"selenium",
")",
")",
"{",
"$",
"pids",
"=",
"explode"... | Starts selenium server.
### OPTIONS
### EXAMPLE
wp selenium start
@since 1.0.0
@alias run
@access public
@param array $args Unassociated array of arguments passed to this command.
@param array $assoc_args Associated array of arguments passed to this command. | [
"Starts",
"selenium",
"server",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/CLI/Selenium.php#L95-L110 |
10up/wp-codeception | classes/WPCC/CLI/Selenium.php | Selenium.restart | public function restart( $args, $assoc_args ) {
$this->stop( $args, $assoc_args );
$this->start( $args, $assoc_args );
} | php | public function restart( $args, $assoc_args ) {
$this->stop( $args, $assoc_args );
$this->start( $args, $assoc_args );
} | [
"public",
"function",
"restart",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"this",
"->",
"stop",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
";",
"$",
"this",
"->",
"start",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
";",
"}... | Restarts selenium server.
### OPTIONS
### EXAMPLE
wp selenium restart
@since 1.0.0
@access public
@param array $args Unassociated array of arguments passed to this command.
@param array $assoc_args Associated array of arguments passed to this command. | [
"Restarts",
"selenium",
"server",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/CLI/Selenium.php#L127-L130 |
10up/wp-codeception | classes/WPCC/Configuration.php | Configuration.createModule | public static function createModule( $class, $config, $namespace = '' ) {
$hasNamespace = (mb_strpos( $class, '\\' ) !== false);
if ( $hasNamespace ) {
return new $class( $config );
}
// try find module under users suite namespace setting
$className = $namespace . '\\Codeception\\Module\\' . $class;
if ( empty( $namespace ) || ! @class_exists( $className ) ) {
// fallback to default namespace
$className = '\\WPCC\\Module\\' . $class;
if ( ! @class_exists( $className ) ) {
$className = '\\Codeception\\Module\\' . $class;
if ( ! @class_exists( $className ) ) {
throw new ConfigurationException( $class . ' could not be found and loaded' );
}
}
}
return new $className( $config );
} | php | public static function createModule( $class, $config, $namespace = '' ) {
$hasNamespace = (mb_strpos( $class, '\\' ) !== false);
if ( $hasNamespace ) {
return new $class( $config );
}
// try find module under users suite namespace setting
$className = $namespace . '\\Codeception\\Module\\' . $class;
if ( empty( $namespace ) || ! @class_exists( $className ) ) {
// fallback to default namespace
$className = '\\WPCC\\Module\\' . $class;
if ( ! @class_exists( $className ) ) {
$className = '\\Codeception\\Module\\' . $class;
if ( ! @class_exists( $className ) ) {
throw new ConfigurationException( $class . ' could not be found and loaded' );
}
}
}
return new $className( $config );
} | [
"public",
"static",
"function",
"createModule",
"(",
"$",
"class",
",",
"$",
"config",
",",
"$",
"namespace",
"=",
"''",
")",
"{",
"$",
"hasNamespace",
"=",
"(",
"mb_strpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
"!==",
"false",
")",
";",
"if",
"(",... | Creates a new instance of a module and configures it. Module class is
searched and resolves according following rules:
1. if "class" element is fully qualified class name, it will be taken to create module;
2. module class will be searched under default namespace, according $namespace parameter: $namespace . '\Codeception\Module\' . $class;
3. module class will be searched under Codeception and WPCC module namespace, that are "\Codeception\Module" and "\WPCC\Module".
@since 1.0.0
@throws \Codeception\Exception\Configuration
@param string $class The module class name.
@param array $config The module configuration.
@param string $namespace The default namespace for module.
@return \Codeception\Module The module instance. | [
"Creates",
"a",
"new",
"instance",
"of",
"a",
"module",
"and",
"configures",
"it",
".",
"Module",
"class",
"is",
"searched",
"and",
"resolves",
"according",
"following",
"rules",
":"
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Configuration.php#L49-L70 |
10up/wp-codeception | classes/WPCC/Module/WebDriver.php | WebDriver.clickAdminMenu | public function clickAdminMenu( $menu, $parent = null ) {
if ( $parent ) {
$this->click( $parent, '#adminmenu' );
}
$this->click( $menu, '#adminmenu' );
} | php | public function clickAdminMenu( $menu, $parent = null ) {
if ( $parent ) {
$this->click( $parent, '#adminmenu' );
}
$this->click( $menu, '#adminmenu' );
} | [
"public",
"function",
"clickAdminMenu",
"(",
"$",
"menu",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"click",
"(",
"$",
"parent",
",",
"'#adminmenu'",
")",
";",
"}",
"$",
"this",
"->",
"click",... | Clicks admin menu item. Since we are using a WebDriver the first click on
a parent element will lead to opening a submenu group. So if we need to
click on submenu item, we need to do it in two steps.
@since 1.0.0
@access public
@param string $menu The menu item to click on.
@param string $parent The parent menu item to click on first. | [
"Clicks",
"admin",
"menu",
"item",
".",
"Since",
"we",
"are",
"using",
"a",
"WebDriver",
"the",
"first",
"click",
"on",
"a",
"parent",
"element",
"will",
"lead",
"to",
"opening",
"a",
"submenu",
"group",
".",
"So",
"if",
"we",
"need",
"to",
"click",
"o... | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WebDriver.php#L89-L95 |
10up/wp-codeception | classes/WPCC/Module/WebDriver.php | WebDriver.fillTinyMCEField | public function fillTinyMCEField( $editor_id, $value ) {
$script = sprintf( "tinyMCE.get('%s').setContent('%s')", esc_js( $editor_id ), esc_js( $value ) );
$this->webDriver->executeScript( $script );
} | php | public function fillTinyMCEField( $editor_id, $value ) {
$script = sprintf( "tinyMCE.get('%s').setContent('%s')", esc_js( $editor_id ), esc_js( $value ) );
$this->webDriver->executeScript( $script );
} | [
"public",
"function",
"fillTinyMCEField",
"(",
"$",
"editor_id",
",",
"$",
"value",
")",
"{",
"$",
"script",
"=",
"sprintf",
"(",
"\"tinyMCE.get('%s').setContent('%s')\"",
",",
"esc_js",
"(",
"$",
"editor_id",
")",
",",
"esc_js",
"(",
"$",
"value",
")",
")",... | Fills TinyMCE editor.
<pre><code>
<?php
$I->fillTinyMCEField( 'content', 'Lorem ipsum dolor sit...' );
?>
</code></pre>
@since 1.0.0
@access public
@param string $editor_id The TinyMCE's editor id.
@param string $value The value to insert into the editor. | [
"Fills",
"TinyMCE",
"editor",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/WebDriver.php#L112-L115 |
10up/wp-codeception | classes/WPCC/Helper/PageObject/LoginPage.php | LoginPage.login | public function login( $username, $password ) {
$I = $this->_actor;
$I->amOnPage( wp_login_url() );
$I->fillField( self::USERNAME_FIELD, $username );
$I->fillField( self::PASSWORD_FIELD, $password );
$I->click( self::LOGIN_BUTTON );
$I->seeCookie( LOGGED_IN_COOKIE );
return $this;
} | php | public function login( $username, $password ) {
$I = $this->_actor;
$I->amOnPage( wp_login_url() );
$I->fillField( self::USERNAME_FIELD, $username );
$I->fillField( self::PASSWORD_FIELD, $password );
$I->click( self::LOGIN_BUTTON );
$I->seeCookie( LOGGED_IN_COOKIE );
return $this;
} | [
"public",
"function",
"login",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"I",
"=",
"$",
"this",
"->",
"_actor",
";",
"$",
"I",
"->",
"amOnPage",
"(",
"wp_login_url",
"(",
")",
")",
";",
"$",
"I",
"->",
"fillField",
"(",
"self",
"... | Logins as an user.
@since 1.0.0
@access public
@param string $username The username to login with.
@param string $password The user password.
@return \WPCC\Helper\PageObject\LoginPage | [
"Logins",
"as",
"an",
"user",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Helper/PageObject/LoginPage.php#L47-L57 |
10up/wp-codeception | classes/WPCC/Helper/Factory.php | Factory.addTermsFactory | public function addTermsFactory( $factory_name, $taxonomy ) {
// do nothing if factory name is already taken
if ( ! empty( $this->_factories[ $factory_name ] ) ) {
return false;
}
// do nothing if a taxonomy doesn't exist
if ( ! taxonomy_exists( $taxonomy ) ) {
return false;
}
$this->_factories[ $factory_name ] = new TermsFactory( $taxonomy );
return true;
} | php | public function addTermsFactory( $factory_name, $taxonomy ) {
// do nothing if factory name is already taken
if ( ! empty( $this->_factories[ $factory_name ] ) ) {
return false;
}
// do nothing if a taxonomy doesn't exist
if ( ! taxonomy_exists( $taxonomy ) ) {
return false;
}
$this->_factories[ $factory_name ] = new TermsFactory( $taxonomy );
return true;
} | [
"public",
"function",
"addTermsFactory",
"(",
"$",
"factory_name",
",",
"$",
"taxonomy",
")",
"{",
"// do nothing if factory name is already taken",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_factories",
"[",
"$",
"factory_name",
"]",
")",
")",
"{",
"r... | Registers new terms factory.
@since 1.0.0
@access public
@param string $factory_name The factory name.
@param string $taxonomy The taxonomy name.
@return boolean TRUE on success, otherwise FALSE. | [
"Registers",
"new",
"terms",
"factory",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Helper/Factory.php#L116-L130 |
10up/wp-codeception | classes/WPCC/Helper/Factory.php | Factory.cleanup | public function cleanup() {
foreach ( $this->_factories as $factory ) {
if ( $factory instanceof \WPCC\Component\Factory ) {
$factory->deleteAll();
}
}
} | php | public function cleanup() {
foreach ( $this->_factories as $factory ) {
if ( $factory instanceof \WPCC\Component\Factory ) {
$factory->deleteAll();
}
}
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_factories",
"as",
"$",
"factory",
")",
"{",
"if",
"(",
"$",
"factory",
"instanceof",
"\\",
"WPCC",
"\\",
"Component",
"\\",
"Factory",
")",
"{",
"$",
"factory",
"->",
... | Cleans up all factories.
@since 1.0.0
@access public | [
"Cleans",
"up",
"all",
"factories",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Helper/Factory.php#L139-L145 |
10up/wp-codeception | classes/WPCC/Module/Wpdb.php | Wpdb._prepareQuery | protected function _prepareQuery( $table, $columns, $criteria ) {
$where = '1 = 1';
$params = array();
foreach ( $criteria as $column => $value ) {
$pattern = '%s';
if ( is_null( $value ) ) {
$pattern = '%s AND `%s` IS NULL';
} elseif ( is_numeric( $value ) ) {
$pattern = '%s AND `%s` = %%d';
$params[] = $value;
} else {
$pattern = '%s AND `%s` = %%s';
$params[] = $value;
}
$where = sprintf( $pattern, $where, $column );
}
if ( is_array( $columns ) ) {
$columns = implode( ', ', $columns );
}
$query = sprintf( 'SELECT %s FROM %s WHERE %s', $columns, $table, $where );
if ( ! empty( $params ) ) {
$query = $this->_wpdb->prepare( $query, $params );
}
return $query;
} | php | protected function _prepareQuery( $table, $columns, $criteria ) {
$where = '1 = 1';
$params = array();
foreach ( $criteria as $column => $value ) {
$pattern = '%s';
if ( is_null( $value ) ) {
$pattern = '%s AND `%s` IS NULL';
} elseif ( is_numeric( $value ) ) {
$pattern = '%s AND `%s` = %%d';
$params[] = $value;
} else {
$pattern = '%s AND `%s` = %%s';
$params[] = $value;
}
$where = sprintf( $pattern, $where, $column );
}
if ( is_array( $columns ) ) {
$columns = implode( ', ', $columns );
}
$query = sprintf( 'SELECT %s FROM %s WHERE %s', $columns, $table, $where );
if ( ! empty( $params ) ) {
$query = $this->_wpdb->prepare( $query, $params );
}
return $query;
} | [
"protected",
"function",
"_prepareQuery",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"criteria",
")",
"{",
"$",
"where",
"=",
"'1 = 1'",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"column",
"=>... | Builds query.
@since 1.0.0
@access protected
@param string $table The table name.
@param array|string $columns The array of columns to select.
@param array $criteria The array of conditions.
@return string The query string. | [
"Builds",
"query",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/Wpdb.php#L68-L97 |
10up/wp-codeception | classes/WPCC/Module/Wpdb.php | Wpdb.seeInDatabase | public function seeInDatabase( $table, $criteria = array() ) {
$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$res = $this->_wpdb->get_var( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
$this->assertGreaterThan( 0, $res, 'No matching records found' );
} | php | public function seeInDatabase( $table, $criteria = array() ) {
$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$res = $this->_wpdb->get_var( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
$this->assertGreaterThan( 0, $res, 'No matching records found' );
} | [
"public",
"function",
"seeInDatabase",
"(",
"$",
"table",
",",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_prepareQuery",
"(",
"$",
"table",
",",
"'count(*)'",
",",
"$",
"criteria",
")",
";",
"$",
"this"... | Checks whether or not a record exists in the database.
@since 1.0.0
@access public
@param string $table The table name.
@param array $criteria The array of conditions. | [
"Checks",
"whether",
"or",
"not",
"a",
"record",
"exists",
"in",
"the",
"database",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/Wpdb.php#L108-L122 |
10up/wp-codeception | classes/WPCC/Module/Wpdb.php | Wpdb.dontSeeInDatabase | public function dontSeeInDatabase( $table, $criteria = array() ) {
$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$res = $this->_wpdb->get_var( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
$this->assertLessThan( 1, $res, 'Matching records found' );
} | php | public function dontSeeInDatabase( $table, $criteria = array() ) {
$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$res = $this->_wpdb->get_var( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
$this->assertLessThan( 1, $res, 'Matching records found' );
} | [
"public",
"function",
"dontSeeInDatabase",
"(",
"$",
"table",
",",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_prepareQuery",
"(",
"$",
"table",
",",
"'count(*)'",
",",
"$",
"criteria",
")",
";",
"$",
"t... | Checks whether or not a record doesn't exist in the database.
@since 1.0.0
@access public
@param string $table The table name.
@param array $criteria The array of conditions. | [
"Checks",
"whether",
"or",
"not",
"a",
"record",
"doesn",
"t",
"exist",
"in",
"the",
"database",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/Wpdb.php#L133-L147 |
10up/wp-codeception | classes/WPCC/Module/Wpdb.php | Wpdb.grabFromDatabase | public function grabFromDatabase( $table, $columns, $criteria = array() ) {
$query = $this->_prepareQuery( $table, $columns, $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$results = $this->_wpdb->get_results( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
return $results;
} | php | public function grabFromDatabase( $table, $columns, $criteria = array() ) {
$query = $this->_prepareQuery( $table, $columns, $criteria );
$this->debugSection( 'Query', $query );
$suppress_errors = $this->_wpdb->suppress_errors( true );
$results = $this->_wpdb->get_results( $query );
$this->_wpdb->suppress_errors( $suppress_errors );
if ( ! empty( $this->_wpdb->last_error ) ) {
$this->fail( 'Database error: ' . $this->_wpdb->last_error );
return;
}
return $results;
} | [
"public",
"function",
"grabFromDatabase",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_prepareQuery",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"criter... | Fetches rows from database.
@since 1.0.0
@access public
@param string $table The table name.
@param array|string $columns The array of columns to select.
@param array $criteria The array of conditions.
@return array The array of fetched rows. | [
"Fetches",
"rows",
"from",
"database",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Module/Wpdb.php#L160-L174 |
10up/wp-codeception | classes/WPCC/SuiteManager.php | SuiteManager.initializeModules | protected function initializeModules() {
self::$modules = Configuration::modules( $this->settings );
self::$actions = Configuration::actions( self::$modules );
foreach ( self::$modules as $module ) {
$module->_initialize();
}
} | php | protected function initializeModules() {
self::$modules = Configuration::modules( $this->settings );
self::$actions = Configuration::actions( self::$modules );
foreach ( self::$modules as $module ) {
$module->_initialize();
}
} | [
"protected",
"function",
"initializeModules",
"(",
")",
"{",
"self",
"::",
"$",
"modules",
"=",
"Configuration",
"::",
"modules",
"(",
"$",
"this",
"->",
"settings",
")",
";",
"self",
"::",
"$",
"actions",
"=",
"Configuration",
"::",
"actions",
"(",
"self"... | Initializes modules.
@since 1.0.0
@access protected | [
"Initializes",
"modules",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/SuiteManager.php#L60-L67 |
10up/wp-codeception | classes/WPCC/Command/Run.php | Run.execute | public function execute( InputInterface $input, OutputInterface $output ) {
$this->options = $input->getOptions();
$this->output = $output;
$config = Configuration::config( $this->options['config'] );
if ( ! $this->options['colors'] ) {
$this->options['colors'] = $config['settings']['colors'];
}
if ( ! $this->options['silent'] ) {
$this->output->writeln( Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString() );
}
if ( $this->options['debug'] ) {
$this->output->setVerbosity( OutputInterface::VERBOSITY_VERY_VERBOSE );
}
$userOptions = array_intersect_key( $this->options, array_flip( $this->passedOptionKeys( $input ) ) );
$userOptions = array_merge( $userOptions, $this->booleanOptions( $input, ['xml', 'html', 'json', 'tap', 'coverage', 'coverage-xml', 'coverage-html' ] ) );
$userOptions['verbosity'] = $this->output->getVerbosity();
$userOptions['interactive'] = ! $input->hasParameterOption( array( '--no-interaction', '-n' ) );
if ( $this->options['no-colors'] ) {
$userOptions['colors'] = false;
}
if ( $this->options['group'] ) {
$userOptions['groups'] = $this->options['group'];
}
if ( $this->options['skip-group'] ) {
$userOptions['excludeGroups'] = $this->options['skip-group'];
}
if ( $this->options['report'] ) {
$userOptions['silent'] = true;
}
if ( $this->options['coverage-xml'] || $this->options['coverage-html'] || $this->options['coverage-text'] ) {
$this->options['coverage'] = true;
}
$suite = $input->getArgument( 'suite' );
$test = $input->getArgument( 'test' );
if ( ! Configuration::isEmpty() && ! $test && strpos( $suite, $config['paths']['tests'] ) === 0 ) {
list( $matches, $suite, $test ) = $this->matchTestFromFilename( $suite, $config['paths']['tests'] );
}
if ( $this->options['group'] ) {
$this->output->writeln( sprintf( "[Groups] <info>%s</info> ", implode( ', ', $this->options['group'] ) ) );
}
if ( $input->getArgument( 'test' ) ) {
$this->options['steps'] = true;
}
if ( $test ) {
$filter = $this->matchFilteredTestNameEx( $test );
$userOptions['filter'] = $filter;
}
$this->codecept = new Codecept( $userOptions );
if ( $suite && $test ) {
$this->codecept->run( $suite, $test );
}
if ( ! $test ) {
$suites = $suite ? explode( ',', $suite ) : Configuration::suites();
$this->executed = $this->runSuites( $suites, $this->options['skip'] );
if ( !empty( $config['include'] ) ) {
$current_dir = Configuration::projectDir();
$suites += $config['include'];
$this->runIncludedSuites( $config['include'], $current_dir );
}
if ( $this->executed === 0 ) {
throw new \RuntimeException(
sprintf( "Suite '%s' could not be found", implode( ', ', $suites ) )
);
}
}
$this->codecept->printResult();
if ( ! $input->getOption( 'no-exit' ) ) {
if ( ! $this->codecept->getResult()->wasSuccessful() ) {
exit( 1 );
}
}
} | php | public function execute( InputInterface $input, OutputInterface $output ) {
$this->options = $input->getOptions();
$this->output = $output;
$config = Configuration::config( $this->options['config'] );
if ( ! $this->options['colors'] ) {
$this->options['colors'] = $config['settings']['colors'];
}
if ( ! $this->options['silent'] ) {
$this->output->writeln( Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString() );
}
if ( $this->options['debug'] ) {
$this->output->setVerbosity( OutputInterface::VERBOSITY_VERY_VERBOSE );
}
$userOptions = array_intersect_key( $this->options, array_flip( $this->passedOptionKeys( $input ) ) );
$userOptions = array_merge( $userOptions, $this->booleanOptions( $input, ['xml', 'html', 'json', 'tap', 'coverage', 'coverage-xml', 'coverage-html' ] ) );
$userOptions['verbosity'] = $this->output->getVerbosity();
$userOptions['interactive'] = ! $input->hasParameterOption( array( '--no-interaction', '-n' ) );
if ( $this->options['no-colors'] ) {
$userOptions['colors'] = false;
}
if ( $this->options['group'] ) {
$userOptions['groups'] = $this->options['group'];
}
if ( $this->options['skip-group'] ) {
$userOptions['excludeGroups'] = $this->options['skip-group'];
}
if ( $this->options['report'] ) {
$userOptions['silent'] = true;
}
if ( $this->options['coverage-xml'] || $this->options['coverage-html'] || $this->options['coverage-text'] ) {
$this->options['coverage'] = true;
}
$suite = $input->getArgument( 'suite' );
$test = $input->getArgument( 'test' );
if ( ! Configuration::isEmpty() && ! $test && strpos( $suite, $config['paths']['tests'] ) === 0 ) {
list( $matches, $suite, $test ) = $this->matchTestFromFilename( $suite, $config['paths']['tests'] );
}
if ( $this->options['group'] ) {
$this->output->writeln( sprintf( "[Groups] <info>%s</info> ", implode( ', ', $this->options['group'] ) ) );
}
if ( $input->getArgument( 'test' ) ) {
$this->options['steps'] = true;
}
if ( $test ) {
$filter = $this->matchFilteredTestNameEx( $test );
$userOptions['filter'] = $filter;
}
$this->codecept = new Codecept( $userOptions );
if ( $suite && $test ) {
$this->codecept->run( $suite, $test );
}
if ( ! $test ) {
$suites = $suite ? explode( ',', $suite ) : Configuration::suites();
$this->executed = $this->runSuites( $suites, $this->options['skip'] );
if ( !empty( $config['include'] ) ) {
$current_dir = Configuration::projectDir();
$suites += $config['include'];
$this->runIncludedSuites( $config['include'], $current_dir );
}
if ( $this->executed === 0 ) {
throw new \RuntimeException(
sprintf( "Suite '%s' could not be found", implode( ', ', $suites ) )
);
}
}
$this->codecept->printResult();
if ( ! $input->getOption( 'no-exit' ) ) {
if ( ! $this->codecept->getResult()->wasSuccessful() ) {
exit( 1 );
}
}
} | [
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"input",
"->",
"getOptions",
"(",
")",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
... | Executes Run command
@since 1.0.0
@throws \RuntimeException When a suite is not found.
@access public
@param \Symfony\Component\Console\Input\InputInterface $input The input arguments.
@param \Symfony\Component\Console\Output\OutputInterface $output The output interface. | [
"Executes",
"Run",
"command"
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Command/Run.php#L47-L135 |
10up/wp-codeception | classes/WPCC/Component/Factory/Post.php | Post._createObject | protected function _createObject( $args ) {
$post_id = wp_insert_post( $args, true );
if ( $post_id && ! is_wp_error( $post_id ) ) {
$this->_debug( 'Generated post ID: ' . $post_id );
} elseif ( is_wp_error( $post_id ) ) {
$this->_debug(
'Post generation failed with message [%s] %s',
$post_id->get_error_code(),
$post_id->get_error_messages()
);
} else {
$this->_debug( 'Post generation failed' );
}
return $post_id;
} | php | protected function _createObject( $args ) {
$post_id = wp_insert_post( $args, true );
if ( $post_id && ! is_wp_error( $post_id ) ) {
$this->_debug( 'Generated post ID: ' . $post_id );
} elseif ( is_wp_error( $post_id ) ) {
$this->_debug(
'Post generation failed with message [%s] %s',
$post_id->get_error_code(),
$post_id->get_error_messages()
);
} else {
$this->_debug( 'Post generation failed' );
}
return $post_id;
} | [
"protected",
"function",
"_createObject",
"(",
"$",
"args",
")",
"{",
"$",
"post_id",
"=",
"wp_insert_post",
"(",
"$",
"args",
",",
"true",
")",
";",
"if",
"(",
"$",
"post_id",
"&&",
"!",
"is_wp_error",
"(",
"$",
"post_id",
")",
")",
"{",
"$",
"this"... | Generates a new post.
@since 1.0.0
@access protected
@param array $args The array of arguments to use during a new post creation.
@return int|\WP_Error The newly created post's ID on success, otherwise a WP_Error object. | [
"Generates",
"a",
"new",
"post",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory/Post.php#L61-L76 |
10up/wp-codeception | classes/WPCC/Component/Factory/Post.php | Post._updateObject | protected function _updateObject( $post_id, $fields ) {
$fields['ID'] = $post_id;
$updated = wp_update_post( $fields );
if ( $updated && ! is_wp_error( $updated ) ) {
$this->_debug( 'Updated post ' . $post_id );
} elseif ( is_wp_error( $updated ) ) {
$this->_debug(
'Update failed for post %d with message [%s] %s',
$post_id,
$updated->get_error_code(),
$updated->get_error_message()
);
} else {
$this->_debug( 'Update failed for post ' . $post_id );
}
return $updated;
} | php | protected function _updateObject( $post_id, $fields ) {
$fields['ID'] = $post_id;
$updated = wp_update_post( $fields );
if ( $updated && ! is_wp_error( $updated ) ) {
$this->_debug( 'Updated post ' . $post_id );
} elseif ( is_wp_error( $updated ) ) {
$this->_debug(
'Update failed for post %d with message [%s] %s',
$post_id,
$updated->get_error_code(),
$updated->get_error_message()
);
} else {
$this->_debug( 'Update failed for post ' . $post_id );
}
return $updated;
} | [
"protected",
"function",
"_updateObject",
"(",
"$",
"post_id",
",",
"$",
"fields",
")",
"{",
"$",
"fields",
"[",
"'ID'",
"]",
"=",
"$",
"post_id",
";",
"$",
"updated",
"=",
"wp_update_post",
"(",
"$",
"fields",
")",
";",
"if",
"(",
"$",
"updated",
"&... | Updates generated object.
@since 1.0.0
@access protected
@param mixed $post_id The post id to update.
@param array $fields The array of fields to update.
@return mixed Updated post ID on success, otherwise 0 or a WP_Error object. | [
"Updates",
"generated",
"object",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory/Post.php#L88-L105 |
10up/wp-codeception | classes/WPCC/Component/Factory/Post.php | Post._deleteObject | protected function _deleteObject( $post_id ) {
$post = get_post( $post_id );
if ( ! $post ) {
return false;
}
$deleted = wp_delete_post( $post_id, true );
if ( $deleted ) {
$this->_debug( 'Deleted post with ID: ' . $post_id );
return true;
}
$this->_debug( 'Post removal failed for ID: ' . $post_id );
return false;
} | php | protected function _deleteObject( $post_id ) {
$post = get_post( $post_id );
if ( ! $post ) {
return false;
}
$deleted = wp_delete_post( $post_id, true );
if ( $deleted ) {
$this->_debug( 'Deleted post with ID: ' . $post_id );
return true;
}
$this->_debug( 'Post removal failed for ID: ' . $post_id );
return false;
} | [
"protected",
"function",
"_deleteObject",
"(",
"$",
"post_id",
")",
"{",
"$",
"post",
"=",
"get_post",
"(",
"$",
"post_id",
")",
";",
"if",
"(",
"!",
"$",
"post",
")",
"{",
"return",
"false",
";",
"}",
"$",
"deleted",
"=",
"wp_delete_post",
"(",
"$",... | Deletes previously generated post object.
@since 1.0.0
@access protected
@param int $post_id The post id to delete.
@return boolean TRUE on success, otherwise FALSE. | [
"Deletes",
"previously",
"generated",
"post",
"object",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory/Post.php#L116-L130 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory._debug | protected function _debug( $message, $args = null ) {
$message = '[Factory] ' . $message;
if ( func_num_args() == 1 ) {
Debug::debug( $message );
} else {
$args = array_slice( func_get_args(), 1 );
Debug::debugf( $message, $args );
}
} | php | protected function _debug( $message, $args = null ) {
$message = '[Factory] ' . $message;
if ( func_num_args() == 1 ) {
Debug::debug( $message );
} else {
$args = array_slice( func_get_args(), 1 );
Debug::debugf( $message, $args );
}
} | [
"protected",
"function",
"_debug",
"(",
"$",
"message",
",",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"'[Factory] '",
".",
"$",
"message",
";",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"Debug",
"::",
"debug",
"(",
... | Displays debug message.
@since 1.0.2
@access protected
@param string $message Debug message.
@param array $args Debug arguments. | [
"Displays",
"debug",
"message",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L79-L88 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory.create | public function create( $args = array(), $definitions = null ) {
if ( is_null( $definitions ) ) {
$definitions = $this->_definitions;
}
$callbacks = array();
$generated_args = $this->_generateArgs( $args, $definitions, $callbacks );
if ( is_wp_error( $generated_args ) ) {
return $generated_args;
}
$created = $this->_createObject( $generated_args );
if ( ! $created || is_wp_error( $created ) ) {
return $created;
}
if ( ! empty( $callbacks ) ) {
$updated_fields = $this->_applyCallbacks( $callbacks, $created );
$save_result = $this->_updateObject( $created, $updated_fields );
if ( ! $save_result || is_wp_error( $save_result ) ) {
return $save_result;
}
}
if ( ! empty( $created ) && !is_wp_error( $created ) ) {
$this->_objects[] = $created;
}
return $created;
} | php | public function create( $args = array(), $definitions = null ) {
if ( is_null( $definitions ) ) {
$definitions = $this->_definitions;
}
$callbacks = array();
$generated_args = $this->_generateArgs( $args, $definitions, $callbacks );
if ( is_wp_error( $generated_args ) ) {
return $generated_args;
}
$created = $this->_createObject( $generated_args );
if ( ! $created || is_wp_error( $created ) ) {
return $created;
}
if ( ! empty( $callbacks ) ) {
$updated_fields = $this->_applyCallbacks( $callbacks, $created );
$save_result = $this->_updateObject( $created, $updated_fields );
if ( ! $save_result || is_wp_error( $save_result ) ) {
return $save_result;
}
}
if ( ! empty( $created ) && !is_wp_error( $created ) ) {
$this->_objects[] = $created;
}
return $created;
} | [
"public",
"function",
"create",
"(",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"definitions",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"definitions",
")",
")",
"{",
"$",
"definitions",
"=",
"$",
"this",
"->",
"_definitions",
";",
... | Creates a new object.
@since 1.0.0
@access public
@param array $args The array of arguments to use during a new object creation.
@param array $definitions Custom difinitions of default values for a new object properties.
@return object|boolean|\WP_Error A new object identifier on success, otherwise FALSE or a WP_Error object. | [
"Creates",
"a",
"new",
"object",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L149-L178 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory.createAndGet | public function createAndGet( $args = array(), $definitions = null ) {
$object_id = $this->create( $args, $definitions );
if ( ! $object_id || is_wp_error( $object_id ) ) {
return $object_id;
}
return $this->getObjectById( $object_id );
} | php | public function createAndGet( $args = array(), $definitions = null ) {
$object_id = $this->create( $args, $definitions );
if ( ! $object_id || is_wp_error( $object_id ) ) {
return $object_id;
}
return $this->getObjectById( $object_id );
} | [
"public",
"function",
"createAndGet",
"(",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"definitions",
"=",
"null",
")",
"{",
"$",
"object_id",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"args",
",",
"$",
"definitions",
")",
";",
"if",
"(",
"!",... | Creates a new object and returns it.
@since 1.0.0
@access public
@param array $args The array of arguments to use during a new object creation.
@param array $definitions Custom difinitions of default values for a new object properties.
@return object|boolean|\WP_Error A new object on success, otherwise FALSE or a WP_Error object. | [
"Creates",
"a",
"new",
"object",
"and",
"returns",
"it",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L190-L197 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory.createMany | public function createMany( $count, $args = array(), $definitions = null ) {
$results = array();
for ( $i = 0; $i < $count; $i++ ) {
$results[] = $this->create( $args, $definitions );
}
return $results;
} | php | public function createMany( $count, $args = array(), $definitions = null ) {
$results = array();
for ( $i = 0; $i < $count; $i++ ) {
$results[] = $this->create( $args, $definitions );
}
return $results;
} | [
"public",
"function",
"createMany",
"(",
"$",
"count",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"definitions",
"=",
"null",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
... | Creates many new objects and returns their ids.
@since 1.0.0
@access public
@param int $count The number of objects to created.
@param array $args The array of arguments to use during a new object creation.
@param array $definitions Custom difinitions of default values for a new object properties.
@return array The array of generated object ids. | [
"Creates",
"many",
"new",
"objects",
"and",
"returns",
"their",
"ids",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L210-L217 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory.delete | public function delete( $object ) {
// do nothing if an object was generated not by this factory
if ( ! in_array( $object, $this->_objects ) ) {
return false;
}
// delete object and remove it from the objects list
$deleted = $this->_deleteObject( $object );
if ( $deleted && ! is_wp_error( $deleted ) ) {
$index = array_search( $object, $this->_objects );
if ( false !== $index ) {
unset( $this->_objects[ $index ] );
}
}
return $deleted;
} | php | public function delete( $object ) {
// do nothing if an object was generated not by this factory
if ( ! in_array( $object, $this->_objects ) ) {
return false;
}
// delete object and remove it from the objects list
$deleted = $this->_deleteObject( $object );
if ( $deleted && ! is_wp_error( $deleted ) ) {
$index = array_search( $object, $this->_objects );
if ( false !== $index ) {
unset( $this->_objects[ $index ] );
}
}
return $deleted;
} | [
"public",
"function",
"delete",
"(",
"$",
"object",
")",
"{",
"// do nothing if an object was generated not by this factory",
"if",
"(",
"!",
"in_array",
"(",
"$",
"object",
",",
"$",
"this",
"->",
"_objects",
")",
")",
"{",
"return",
"false",
";",
"}",
"// de... | Deletes an object generated by this factory instance.
@since 1.0.0
@access public
@param mixed $object The generated object.
@return boolean|\WP_Error TRUE on success, otherwise FALSE or WP_Error object. | [
"Deletes",
"an",
"object",
"generated",
"by",
"this",
"factory",
"instance",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L228-L244 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory._generateArgs | protected function _generateArgs( $args, $definitions, &$callbacks = array() ) {
foreach ( $definitions as $field => $generator ) {
if ( isset( $args[ $field ] ) ) {
continue;
}
if ( is_scalar( $generator ) ) {
$args[ $field ] = $generator;
} elseif ( $generator instanceof AfterCreateCallback ) {
$callbacks[ $field ] = $generator;
} elseif ( $generator instanceof Sequence ) {
$args[ $field ] = $generator->next();
} else {
return new \WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' );
}
}
return $args;
} | php | protected function _generateArgs( $args, $definitions, &$callbacks = array() ) {
foreach ( $definitions as $field => $generator ) {
if ( isset( $args[ $field ] ) ) {
continue;
}
if ( is_scalar( $generator ) ) {
$args[ $field ] = $generator;
} elseif ( $generator instanceof AfterCreateCallback ) {
$callbacks[ $field ] = $generator;
} elseif ( $generator instanceof Sequence ) {
$args[ $field ] = $generator->next();
} else {
return new \WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' );
}
}
return $args;
} | [
"protected",
"function",
"_generateArgs",
"(",
"$",
"args",
",",
"$",
"definitions",
",",
"&",
"$",
"callbacks",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"field",
"=>",
"$",
"generator",
")",
"{",
"if",
"(",
"i... | Generates arguments for a new object.
@since 1.0.0
@access protected
@param array $args The initial set of arguments.
@param array $definitions The definitions for auto generated properties.
@param array $callbacks The array of callbacks.
@return array|\WP_Error The array of arguments on success, otherwise a WP_Error object. | [
"Generates",
"arguments",
"for",
"a",
"new",
"object",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L270-L288 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory._applyCallbacks | protected function _applyCallbacks( $callbacks, $created ) {
$updated_fields = array();
foreach ( $callbacks as $field => $callback ) {
$updated_fields[ $field ] = $callback->call( $created );
}
return $updated_fields;
} | php | protected function _applyCallbacks( $callbacks, $created ) {
$updated_fields = array();
foreach ( $callbacks as $field => $callback ) {
$updated_fields[ $field ] = $callback->call( $created );
}
return $updated_fields;
} | [
"protected",
"function",
"_applyCallbacks",
"(",
"$",
"callbacks",
",",
"$",
"created",
")",
"{",
"$",
"updated_fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"callbacks",
"as",
"$",
"field",
"=>",
"$",
"callback",
")",
"{",
"$",
"updated_fie... | Applies callbacks and returns updated fields.
@since 1.0.0
@access protected
@param array $callbacks The array of callbacks to call.
@param mixed $created The newly created object.
@return array The array of updated fields. | [
"Applies",
"callbacks",
"and",
"returns",
"updated",
"fields",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L300-L307 |
10up/wp-codeception | classes/WPCC/Component/Factory.php | Factory._addSlashesDeep | protected function _addSlashesDeep( $value ) {
if ( is_array( $value ) ) {
$value = array_map( array( $this, '_addSlashesDeep' ), $value );
} elseif ( is_object( $value ) ) {
$vars = get_object_vars( $value );
foreach ( $vars as $key => $data ) {
$value->{$key} = $this->_addSlashesDeep( $data );
}
} elseif ( is_string( $value ) ) {
$value = addslashes( $value );
}
return $value;
} | php | protected function _addSlashesDeep( $value ) {
if ( is_array( $value ) ) {
$value = array_map( array( $this, '_addSlashesDeep' ), $value );
} elseif ( is_object( $value ) ) {
$vars = get_object_vars( $value );
foreach ( $vars as $key => $data ) {
$value->{$key} = $this->_addSlashesDeep( $data );
}
} elseif ( is_string( $value ) ) {
$value = addslashes( $value );
}
return $value;
} | [
"protected",
"function",
"_addSlashesDeep",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'_addSlashesDeep'",
")",
",",
"$",
"value",
")",
"... | Adds slashes recursively to each item of incomming value.
@since 1.0.0
@access protected
@param mixed $value The incomming value to add slashes to.
@return mixed Updated value with slashes. | [
"Adds",
"slashes",
"recursively",
"to",
"each",
"item",
"of",
"incomming",
"value",
"."
] | train | https://github.com/10up/wp-codeception/blob/9eb60dc0fe2a1374cdf78f7308932f5212f85304/classes/WPCC/Component/Factory.php#L331-L344 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.