->getRepository('WallabagAnnotationBundle:Annotation')
->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
$total = count($annotationRows);
- $annotations = array('total' => $total, 'rows' => $annotationRows);
+ $annotations = ['total' => $total, 'rows' => $annotationRows];
$json = $this->get('serializer')->serialize($annotations, 'json');
*/
private function renderJsonResponse($json, $code = 200)
{
- return new Response($json, $code, array('application/json'));
+ return new Response($json, $code, ['application/json']);
}
}
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('admin');
- $headers = array('CONTENT_TYPE' => 'application/json');
- $content = json_encode(array(
+ $headers = ['CONTENT_TYPE' => 'application/json'];
+ $content = json_encode([
'text' => 'my annotation',
'quote' => 'my quote',
- 'ranges' => array('start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31),
- ));
- $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', array(), array(), $headers, $content);
+ 'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
+ ]);
+ $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$this->logInAs('admin');
- $headers = array('CONTENT_TYPE' => 'application/json');
- $content = json_encode(array(
+ $headers = ['CONTENT_TYPE' => 'application/json'];
+ $content = json_encode([
'text' => 'a modified annotation',
- ));
- $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
+ ]);
+ $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->logInAs('admin');
- $headers = array('CONTENT_TYPE' => 'application/json');
- $content = json_encode(array(
+ $headers = ['CONTENT_TYPE' => 'application/json'];
+ $content = json_encode([
'text' => 'a modified annotation',
- ));
- $crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
+ ]);
+ $crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
{
$crawler = $this->client->request('GET', '/login');
$form = $crawler->filter('button[type=submit]')->form();
- $data = array(
+ $data = [
'_username' => $username,
'_password' => 'mypassword',
- );
+ ];
$this->client->submit($form, $data);
}
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
- $this->user = $userManager->findUserBy(array('username' => 'admin'));
+ $this->user = $userManager->findUserBy(['username' => 'admin']);
$loginManager->loginUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie
*/
private function renderJsonResponse($json)
{
- return new Response($json, 200, array('application/json'));
+ return new Response($json, 200, ['application/json']);
}
}
$entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneBy(array('user' => 1, 'isArchived' => false));
+ ->findOneBy(['user' => 1, 'isArchived' => false]);
if (!$entry) {
$this->markTestSkipped('No content found in db.');
$entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
- ->findOneBy(array('user' => 2, 'isArchived' => false));
+ ->findOneBy(['user' => 2, 'isArchived' => false]);
if (!$entry) {
$this->markTestSkipped('No content found in db.');
public function testGetStarredEntries()
{
- $this->client->request('GET', '/api/entries', array('star' => 1, 'sort' => 'updated'));
+ $this->client->request('GET', '/api/entries', ['star' => 1, 'sort' => 'updated']);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
public function testGetArchiveEntries()
{
- $this->client->request('GET', '/api/entries', array('archive' => 1));
+ $this->client->request('GET', '/api/entries', ['archive' => 1]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
public function testPostEntry()
{
- $this->client->request('POST', '/api/entries.json', array(
+ $this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'tags' => 'google',
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
public function testPostSameEntry()
{
- $this->client->request('POST', '/api/entries.json', array(
+ $this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'archive' => '1',
'tags' => 'google, apple',
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
public function testPostArchivedAndStarredEntry()
{
- $this->client->request('POST', '/api/entries.json', array(
+ $this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
'archive' => '1',
'starred' => '1',
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
public function testPostArchivedAndStarredEntryWithoutQuotes()
{
- $this->client->request('POST', '/api/entries.json', array(
+ $this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
'archive' => 0,
'starred' => 1,
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
// hydrate the tags relations
$nbTags = count($entry->getTags());
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array(
+ $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
'title' => 'New awesome title',
'tags' => 'new tag '.uniqid(),
'starred' => '1',
'archive' => '0',
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
// hydrate the tags relations
$nbTags = count($entry->getTags());
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array(
+ $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
'title' => 'New awesome title',
'tags' => 'new tag '.uniqid(),
'starred' => 1,
'archive' => 0,
- ));
+ ]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$this->markTestSkipped('No content found in db.');
}
- $tags = array();
+ $tags = [];
foreach ($entry->getTags() as $tag) {
- $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug());
+ $tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
}
$this->client->request('GET', '/api/entries/'.$entry->getId().'/tags');
$newTags = 'tag1,tag2,tag3';
- $this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', array('tags' => $newTags));
+ $this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
- $tagsInDB = array();
+ $tagsInDB = [];
foreach ($entryDB->getTags()->toArray() as $tag) {
$tagsInDB[$tag->getId()] = $tag->getLabel();
}
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
- $this->user = $userManager->findUserBy(array('username' => 'admin'));
+ $this->user = $userManager->findUserBy(['username' => 'admin']);
$loginManager->loginUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie
$user = $this->getUser();
// handle basic config detail (this form is defined as a service)
- $configForm = $this->createForm(ConfigType::class, $config, array('action' => $this->generateUrl('config')));
+ $configForm = $this->createForm(ConfigType::class, $config, ['action' => $this->generateUrl('config')]);
$configForm->handleRequest($request);
if ($configForm->isValid()) {
}
// handle changing password
- $pwdForm = $this->createForm(ChangePasswordType::class, null, array('action' => $this->generateUrl('config').'#set4'));
+ $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']);
$pwdForm->handleRequest($request);
if ($pwdForm->isValid()) {
}
// handle changing user information
- $userForm = $this->createForm(UserInformationType::class, $user, array(
- 'validation_groups' => array('Profile'),
+ $userForm = $this->createForm(UserInformationType::class, $user, [
+ 'validation_groups' => ['Profile'],
'action' => $this->generateUrl('config').'#set3',
- ));
+ ]);
$userForm->handleRequest($request);
if ($userForm->isValid()) {
}
// handle rss information
- $rssForm = $this->createForm(RssType::class, $config, array('action' => $this->generateUrl('config').'#set2'));
+ $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']);
$rssForm->handleRequest($request);
if ($rssForm->isValid()) {
// handle tagging rule
$taggingRule = new TaggingRule();
- $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, array('action' => $this->generateUrl('config').'#set5'));
+ $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']);
$newTaggingRule->handleRequest($request);
if ($newTaggingRule->isValid()) {
$newUser = $userManager->createUser();
// enable created user by default
$newUser->setEnabled(true);
- $newUserForm = $this->createForm(NewUserType::class, $newUser, array(
- 'validation_groups' => array('Profile'),
+ $newUserForm = $this->createForm(NewUserType::class, $newUser, [
+ 'validation_groups' => ['Profile'],
'action' => $this->generateUrl('config').'#set6',
- ));
+ ]);
$newUserForm->handleRequest($request);
if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
$this->get('session')->getFlashBag()->add(
'notice',
- $this->get('translator')->trans('flashes.config.notice.user_added', array('%username%' => $newUser->getUsername()))
+ $this->get('translator')->trans('flashes.config.notice.user_added', ['%username%' => $newUser->getUsername()])
);
return $this->redirect($this->generateUrl('config').'#set6');
}
- return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
- 'form' => array(
+ return $this->render('WallabagCoreBundle:Config:index.html.twig', [
+ 'form' => [
'config' => $configForm->createView(),
'rss' => $rssForm->createView(),
'pwd' => $pwdForm->createView(),
'user' => $userForm->createView(),
'new_user' => $newUserForm->createView(),
'new_tagging_rule' => $newTaggingRule->createView(),
- ),
- 'rss' => array(
+ ],
+ 'rss' => [
'username' => $user->getUsername(),
'token' => $config->getRssToken(),
- ),
+ ],
'twofactor_auth' => $this->getParameter('twofactor_auth'),
- ));
+ ]);
}
/**
$em->flush();
if ($request->isXmlHttpRequest()) {
- return new JsonResponse(array('token' => $config->getRssToken()));
+ return new JsonResponse(['token' => $config->getRssToken()]);
}
$this->get('session')->getFlashBag()->add(
* Retrieve config for the current user.
* If no config were found, create a new one.
*
- * @return Wallabag\CoreBundle\Entity\Config
+ * @return Config
*/
private function getConfig()
{
{
$clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll();
- return $this->render('WallabagCoreBundle:Developer:index.html.twig', array(
+ return $this->render('WallabagCoreBundle:Developer:index.html.twig', [
'clients' => $clients,
- ));
+ ]);
}
/**
$clientForm->handleRequest($request);
if ($clientForm->isValid()) {
- $client->setAllowedGrantTypes(array('token', 'authorization_code', 'password', 'refresh_token'));
+ $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
$em->persist($client);
$em->flush();
'flashes.developer.notice.client_created'
);
- return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', array(
+ return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', [
'client_id' => $client->getPublicId(),
'client_secret' => $client->getSecret(),
- ));
+ ]);
}
- return $this->render('WallabagCoreBundle:Developer:client.html.twig', array(
+ return $this->render('WallabagCoreBundle:Developer:client.html.twig', [
'form' => $clientForm->createView(),
- ));
+ ]);
}
/**
if (false !== $existingEntry) {
$this->get('session')->getFlashBag()->add(
'notice',
- $this->get('translator')->trans('flashes.entry.notice.entry_already_saved', array('%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')))
+ $this->get('translator')->trans('flashes.entry.notice.entry_already_saved', ['%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')])
);
- return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId())));
+ return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
}
$this->updateEntry($entry);
return $this->redirect($this->generateUrl('homepage'));
}
- return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', array(
+ return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', [
'form' => $form->createView(),
- ));
+ ]);
}
/**
'flashes.entry.notice.entry_updated'
);
- return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
+ return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
- return $this->render('WallabagCoreBundle:Entry:edit.html.twig', array(
+ return $this->render('WallabagCoreBundle:Entry:edit.html.twig', [
'form' => $form->createView(),
- ));
+ ]);
}
/**
$entries->setCurrentPage($page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
- return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302);
+ return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
}
}
return $this->render(
'WallabagCoreBundle:Entry:entries.html.twig',
- array(
+ [
'form' => $form->createView(),
'entries' => $entries,
'currentPage' => $page,
- )
+ ]
);
}
return $this->render(
'WallabagCoreBundle:Entry:entry.html.twig',
- array('entry' => $entry)
+ ['entry' => $entry]
);
}
$message
);
- return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
+ return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
/**
// to avoid redirecting to the deleted entry. Ugh.
$url = $this->generateUrl(
'view',
- array('id' => $entry->getId()),
+ ['id' => $entry->getId()],
UrlGeneratorInterface::ABSOLUTE_URL
);
/**
* Check for existing entry, if it exists, redirect to it with a message.
*
- * @param $entry
+ * @param Entry $entry
*
- * @return array|bool
+ * @return Entry|bool
*/
- private function checkIfEntryAlreadyExists($entry)
+ private function checkIfEntryAlreadyExists(Entry $entry)
{
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
}
/**
* Gets one entry content.
*
- * @param Entry $entry
+ * @param Entry $entry
+ * @param string $format
*
* @Route("/export/{id}.{format}", name="export_entry", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv",
* "id": "\d+"
* })
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
*/
public function downloadEntryAction(Entry $entry, $format)
{
/**
* Export all entries for current user.
*
+ * @param string $format
+ * @param string $category
+ *
* @Route("/export/{category}.{format}", name="export_entries", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv",
* "category": "all|unread|starred|archive"
* })
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
*/
public function downloadEntriesAction($format, $category)
{
$perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit');
$entries->setMaxPerPage($perPage);
- return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
+ return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', [
'type' => $type,
'entries' => $entries,
- ));
+ ]);
}
}
{
return $this->render(
'WallabagCoreBundle:Static:howto.html.twig',
- array()
+ []
);
}
{
return $this->render(
'WallabagCoreBundle:Static:about.html.twig',
- array(
+ [
'version' => $this->getParameter('wallabag_core.version'),
'paypal_url' => $this->getParameter('wallabag_core.paypal_url'),
- )
+ ]
);
}
{
return $this->render(
'WallabagCoreBundle:Static:quickstart.html.twig',
- array()
+ []
);
}
}
{
/**
* @param Request $request
+ * @param Entry $entry
*
* @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
*
'flashes.tag.notice.tag_added'
);
- return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
+ return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
- return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array(
+ return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', [
'form' => $form->createView(),
'entry' => $entry,
- ));
+ ]);
}
/**
return $this->render(
'WallabagCoreBundle:Tag:tags.html.twig',
- array(
+ [
'tags' => $tags,
- )
+ ]
);
}
}
{
$tr1 = new TaggingRule();
$tr1->setRule('content matches "spurs"');
- $tr1->setTags(array('sport'));
+ $tr1->setTags(['sport']);
$tr1->setConfig($this->getReference('admin-config'));
$manager->persist($tr1);
$tr2 = new TaggingRule();
$tr2->setRule('content matches "basket"');
- $tr2->setTags(array('sport'));
+ $tr2->setTags(['sport']);
$tr2->setConfig($this->getReference('admin-config'));
$manager->persist($tr2);
public static function getSubscribedEvents()
{
- return array(
+ return [
// must be registered before the default Locale listener
- KernelEvents::REQUEST => array(array('onKernelRequest', 17)),
- );
+ KernelEvents::REQUEST => [['onKernelRequest', 17]],
+ ];
}
}
public static function getSubscribedEvents()
{
- return array(
+ return [
FOSUserEvents::REGISTRATION_CONFIRMED => 'authenticate',
- );
+ ];
}
public function authenticate(FilterUserResponseEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('old_password', PasswordType::class, array(
- 'constraints' => new UserPassword(array('message' => 'validator.password_wrong_value')),
+ ->add('old_password', PasswordType::class, [
+ 'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']),
'label' => 'config.form_password.old_password_label',
- ))
- ->add('new_password', RepeatedType::class, array(
+ ])
+ ->add('new_password', RepeatedType::class, [
'type' => PasswordType::class,
'invalid_message' => 'validator.password_must_match',
'required' => true,
- 'first_options' => array('label' => 'config.form_password.new_password_label'),
- 'second_options' => array('label' => 'config.form_password.repeat_new_password_label'),
- 'constraints' => array(
- new Constraints\Length(array(
+ 'first_options' => ['label' => 'config.form_password.new_password_label'],
+ 'second_options' => ['label' => 'config.form_password.repeat_new_password_label'],
+ 'constraints' => [
+ new Constraints\Length([
'min' => 8,
'minMessage' => 'validator.password_too_short',
- )),
+ ]),
new Constraints\NotBlank(),
- ),
+ ],
'label' => 'config.form_password.new_password_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('redirect_uris', UrlType::class, array('required' => true, 'label' => 'developer.client.form.redirect_uris_label'))
- ->add('save', SubmitType::class, array('label' => 'developer.client.form.save_label'))
+ ->add('redirect_uris', UrlType::class, ['required' => true, 'label' => 'developer.client.form.redirect_uris_label'])
+ ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
;
$builder->get('redirect_uris')
return $originalUri;
},
function ($submittedUri) {
- return array($submittedUri);
+ return [$submittedUri];
}
))
;
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\ApiBundle\Entity\Client',
- ));
+ ]);
}
public function getBlockPrefix()
class ConfigType extends AbstractType
{
- private $themes = array();
- private $languages = array();
+ private $themes = [];
+ private $languages = [];
/**
* @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('theme', ChoiceType::class, array(
+ ->add('theme', ChoiceType::class, [
'choices' => array_flip($this->themes),
'choices_as_values' => true,
'label' => 'config.form_settings.theme_label',
- ))
- ->add('items_per_page', null, array(
+ ])
+ ->add('items_per_page', null, [
'label' => 'config.form_settings.items_per_page_label',
- ))
- ->add('reading_speed', ChoiceType::class, array(
+ ])
+ ->add('reading_speed', ChoiceType::class, [
'label' => 'config.form_settings.reading_speed.label',
- 'choices' => array(
+ 'choices' => [
'config.form_settings.reading_speed.100_word' => '0.5',
'config.form_settings.reading_speed.200_word' => '1',
'config.form_settings.reading_speed.300_word' => '1.5',
'config.form_settings.reading_speed.400_word' => '2',
- ),
- ))
- ->add('language', ChoiceType::class, array(
+ ],
+ ])
+ ->add('language', ChoiceType::class, [
'choices' => array_flip($this->languages),
'choices_as_values' => true,
'label' => 'config.form_settings.language_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Config',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('title', TextType::class, array(
+ ->add('title', TextType::class, [
'required' => true,
'label' => 'entry.edit.title_label',
- ))
- ->add('is_public', CheckboxType::class, array(
+ ])
+ ->add('is_public', CheckboxType::class, [
'required' => false,
'label' => 'entry.edit.is_public_label',
- ))
- ->add('url', TextType::class, array(
+ ])
+ ->add('url', TextType::class, [
'disabled' => true,
'required' => false,
'label' => 'entry.edit.url_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'entry.edit.save_label',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('readingTime', NumberRangeFilterType::class, array(
+ ->add('readingTime', NumberRangeFilterType::class, [
'label' => 'entry.filters.reading_time.label',
- ))
- ->add('createdAt', DateRangeFilterType::class, array(
- 'left_date_options' => array(
- 'attr' => array(
+ ])
+ ->add('createdAt', DateRangeFilterType::class, [
+ 'left_date_options' => [
+ 'attr' => [
'placeholder' => 'dd/mm/yyyy',
- ),
+ ],
'format' => 'dd/MM/yyyy',
'widget' => 'single_text',
- ),
- 'right_date_options' => array(
- 'attr' => array(
+ ],
+ 'right_date_options' => [
+ 'attr' => [
'placeholder' => 'dd/mm/yyyy',
- ),
+ ],
'format' => 'dd/MM/yyyy',
'widget' => 'single_text',
- ),
+ ],
'label' => 'entry.filters.created_at.label',
- )
+ ]
)
- ->add('domainName', TextFilterType::class, array(
+ ->add('domainName', TextFilterType::class, [
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
$value = $values['value'];
if (strlen($value) <= 2 || empty($value)) {
return $filterQuery->createCondition($expression);
},
'label' => 'entry.filters.domain_label',
- ))
- ->add('isArchived', CheckboxFilterType::class, array(
+ ])
+ ->add('isArchived', CheckboxFilterType::class, [
'label' => 'entry.filters.archived_label',
- ))
- ->add('isStarred', CheckboxFilterType::class, array(
+ ])
+ ->add('isStarred', CheckboxFilterType::class, [
'label' => 'entry.filters.starred_label',
- ))
- ->add('previewPicture', CheckboxFilterType::class, array(
+ ])
+ ->add('previewPicture', CheckboxFilterType::class, [
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
if (false === $values['value']) {
return;
return $filterQuery->createCondition($expression);
},
'label' => 'entry.filters.preview_picture_label',
- ))
- ->add('language', ChoiceFilterType::class, array(
+ ])
+ ->add('language', ChoiceFilterType::class, [
'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())),
'choices_as_values' => true,
'label' => 'entry.filters.language_label',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'csrf_protection' => false,
- 'validation_groups' => array('filtering'),
- ));
+ 'validation_groups' => ['filtering'],
+ ]);
}
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('url', UrlType::class, array(
+ ->add('url', UrlType::class, [
'required' => true,
'label' => 'entry.new.form_new.url_label',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('label', TextType::class, array('required' => true))
+ ->add('label', TextType::class, ['required' => true])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Tag',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('username', TextType::class, array(
+ ->add('username', TextType::class, [
'required' => true,
'label' => 'config.form_new_user.username_label',
- ))
- ->add('plainPassword', RepeatedType::class, array(
+ ])
+ ->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'invalid_message' => 'validator.password_must_match',
- 'first_options' => array('label' => 'config.form_new_user.password_label'),
- 'second_options' => array('label' => 'config.form_new_user.repeat_new_password_label'),
- 'constraints' => array(
- new Constraints\Length(array(
+ 'first_options' => ['label' => 'config.form_new_user.password_label'],
+ 'second_options' => ['label' => 'config.form_new_user.repeat_new_password_label'],
+ 'constraints' => [
+ new Constraints\Length([
'min' => 8,
'minMessage' => 'validator.password_too_short',
- )),
+ ]),
new Constraints\NotBlank(),
- ),
+ ],
'label' => 'config.form_new_user.plain_password_label',
- ))
- ->add('email', EmailType::class, array(
+ ])
+ ->add('email', EmailType::class, [
'label' => 'config.form_new_user.email_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\UserBundle\Entity\User',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('rss_limit', null, array(
+ ->add('rss_limit', null, [
'label' => 'config.form_rss.rss_limit',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
;
}
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Config',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('rule', TextType::class, array(
+ ->add('rule', TextType::class, [
'required' => true,
'label' => 'config.form_rules.rule_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
;
$tagsField = $builder
- ->create('tags', TextType::class, array(
+ ->create('tags', TextType::class, [
'label' => 'config.form_rules.tags_label',
- ))
+ ])
->addModelTransformer(new StringToListTransformer(','));
$builder->add($tagsField);
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\TaggingRule',
- ));
+ ]);
}
public function getBlockPrefix()
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('name', TextType::class, array(
+ ->add('name', TextType::class, [
'label' => 'config.form_user.name_label',
- ))
- ->add('email', EmailType::class, array(
+ ])
+ ->add('email', EmailType::class, [
'label' => 'config.form_user.email_label',
- ))
- ->add('twoFactorAuthentication', CheckboxType::class, array(
+ ])
+ ->add('twoFactorAuthentication', CheckboxType::class, [
'required' => false,
'label' => 'config.form_user.twoFactorAuthentication_label',
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'config.form.save',
- ))
+ ])
->remove('username')
->remove('plainPassword')
;
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\UserBundle\Entity\User',
- ));
+ ]);
}
public function getBlockPrefix()
try {
$this->tagger->tag($entry);
} catch (\Exception $e) {
- $this->logger->error('Error while trying to automatically tag an entry.', array(
+ $this->logger->error('Error while trying to automatically tag an entry.', [
'entry_url' => $url,
'error_msg' => $e->getMessage(),
- ));
+ ]);
}
return $entry;
private $wallabagUrl;
private $logoPath;
private $title = '';
- private $entries = array();
- private $authors = array('wallabag');
+ private $entries = [];
+ private $authors = ['wallabag'];
private $language = '';
- private $tags = array();
+ private $tags = [];
private $footerTemplate = '<div style="text-align:center;">
<p>Produced by wallabag with %EXPORT_METHOD%</p>
<p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p>
* Define entries.
*
* @param array|Entry $entries An array of entries or one entry
+ *
+ * @return EntriesExport
*/
public function setEntries($entries)
{
if (!is_array($entries)) {
$this->language = $entries->getLanguage();
- $entries = array($entries);
+ $entries = [$entries];
}
$this->entries = $entries;
* Sets the category of which we want to get articles, or just one entry.
*
* @param string $method Method to get articles
+ *
+ * @return EntriesExport
*/
public function updateTitle($method)
{
* Sets the output format.
*
* @param string $format
+ *
+ * @return Response
*/
public function exportAs($format)
{
/**
* Use PHPePub to dump a .epub file.
+ *
+ * @return Response
*/
private function produceEpub()
{
return Response::create(
$book->getBook(),
200,
- array(
+ [
'Content-Description' => 'File Transfer',
'Content-type' => 'application/epub+zip',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"',
'Content-Transfer-Encoding' => 'binary',
- )
+ ]
);
}
/**
* Use PHPMobi to dump a .mobi file.
+ *
+ * @return Response
*/
private function produceMobi()
{
return Response::create(
$mobi->toString(),
200,
- array(
+ [
'Accept-Ranges' => 'bytes',
'Content-Description' => 'File Transfer',
'Content-type' => 'application/x-mobipocket-ebook',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"',
'Content-Transfer-Encoding' => 'binary',
- )
+ ]
);
}
/**
* Use TCPDF to dump a .pdf file.
+ *
+ * @return Response
*/
private function producePdf()
{
return Response::create(
$pdf->Output('', 'S'),
200,
- array(
+ [
'Content-Description' => 'File Transfer',
'Content-type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"',
'Content-Transfer-Encoding' => 'binary',
- )
+ ]
);
}
/**
* Inspired from CsvFileDumper.
+ *
+ * @return Response
*/
private function produceCsv()
{
$enclosure = '"';
$handle = fopen('php://memory', 'rb+');
- fputcsv($handle, array('Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'), $delimiter, $enclosure);
+ fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'], $delimiter, $enclosure);
foreach ($this->entries as $entry) {
fputcsv(
$handle,
- array(
+ [
$entry->getTitle(),
$entry->getURL(),
// remove new line to avoid crazy results
- str_replace(array("\r\n", "\r", "\n"), '', $entry->getContent()),
+ str_replace(["\r\n", "\r", "\n"], '', $entry->getContent()),
implode(', ', $entry->getTags()->toArray()),
$entry->getMimetype(),
$entry->getLanguage(),
- ),
+ ],
$delimiter,
$enclosure
);
return Response::create(
$output,
200,
- array(
+ [
'Content-type' => 'application/csv',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
'Content-Transfer-Encoding' => 'UTF-8',
- )
+ ]
);
}
+ /**
+ * Dump a JSON file.
+ *
+ * @return Response
+ */
private function produceJson()
{
return Response::create(
$this->prepareSerializingContent('json'),
200,
- array(
+ [
'Content-type' => 'application/json',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
'Content-Transfer-Encoding' => 'UTF-8',
- )
+ ]
);
}
+ /**
+ * Dump a XML file.
+ *
+ * @return Response
+ */
private function produceXml()
{
return Response::create(
$this->prepareSerializingContent('xml'),
200,
- array(
+ [
'Content-type' => 'application/xml',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
'Content-Transfer-Encoding' => 'UTF-8',
- )
+ ]
);
}
+ /**
+ * Dump a TXT file.
+ *
+ * @return Response
+ */
private function produceTxt()
{
$content = '';
return Response::create(
$content,
200,
- array(
+ [
'Content-type' => 'text/plain',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
'Content-Transfer-Encoding' => 'UTF-8',
- )
+ ]
);
}
return $serializer->serialize(
$this->entries,
$format,
- SerializationContext::create()->setGroups(array('entries_for_user'))
+ SerializationContext::create()->setGroups(['entries_for_user'])
);
}
public function tagAllForUser(User $user)
{
$rules = $this->getRulesForUser($user);
- $entries = array();
+ $entries = [];
foreach ($rules as $rule) {
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
->getQuery()
->getResult();
- $languages = array();
+ $languages = [];
foreach ($results as $result) {
$languages[$result['language']] = $result['language'];
}
* @param $url
* @param $userId
*
- * @return array|bool
+ * @return Entry|bool
*/
public function findByUrlAndUserId($url, $userId)
{
public function getSubscribedEvents()
{
- return array('loadClassMetadata');
+ return ['loadClassMetadata'];
}
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
$application = new Application(static::$kernel);
$application->setAutoExit(false);
- $code = $application->run(new ArrayInput(array(
+ $code = $application->run(new ArrayInput([
'command' => 'doctrine:fixtures:load',
'--no-interaction' => true,
'--env' => 'test',
- )), new NullOutput());
+ ]), new NullOutput());
}
public function testRunInstallCommand()
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
'--reset' => true,
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
// drop database first, so the install command won't ask to reset things
$command = $application->find('doctrine:database:drop');
- $command->run(new ArrayInput(array(
+ $command->run(new ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => true,
- )), new NullOutput());
+ ]), new NullOutput());
// start a new application to avoid lagging connexion to pgsql
$client = static::createClient();
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
// drop database first, so the install command won't ask to reset things
$command = new DropDatabaseDoctrineCommand();
$command->setApplication($application);
- $command->run(new ArrayInput(array(
+ $command->run(new ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => true,
- )), new NullOutput());
+ ]), new NullOutput());
$this->getClient()->getContainer()->get('doctrine')->getConnection()->close();
$command = new CreateDatabaseDoctrineCommand();
$command->setApplication($application);
- $command->run(new ArrayInput(array(
+ $command->run(new ArrayInput([
'command' => 'doctrine:database:create',
'--env' => 'test',
- )), new NullOutput());
+ ]), new NullOutput());
$command = $application->find('wallabag:install');
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
'--no-interaction' => true,
- ));
+ ]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
- ));
+ ]);
}
public function testRunTagAllCommandWithBadUsername()
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
'username' => 'unknown',
- ));
+ ]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
}
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
- $tester->execute(array(
+ $tester->execute([
'command' => $command->getName(),
'username' => 'admin',
- ));
+ ]);
$this->assertContains('Tagging entries for user « admin »... Done', $tester->getDisplay());
}
$form = $crawler->filter('button[id=config_save]')->form();
- $data = array(
+ $data = [
'config[theme]' => 'baggy',
'config[items_per_page]' => '30',
'config[reading_speed]' => '0.5',
'config[language]' => 'en',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.config_saved', $alert[0]);
}
public function dataForUpdateFailed()
{
- return array(
- array(array(
+ return [
+ [[
'config[theme]' => 'baggy',
'config[items_per_page]' => '',
'config[language]' => 'en',
- )),
- );
+ ]],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('This value should not be blank', $alert[0]);
}
public function dataForChangePasswordFailed()
{
- return array(
- array(
- array(
+ return [
+ [
+ [
'change_passwd[old_password]' => 'material',
'change_passwd[new_password][first]' => '',
'change_passwd[new_password][second]' => '',
- ),
+ ],
'validator.password_wrong_value',
- ),
- array(
- array(
+ ],
+ [
+ [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => '',
'change_passwd[new_password][second]' => '',
- ),
+ ],
'This value should not be blank',
- ),
- array(
- array(
+ ],
+ [
+ [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'hop',
'change_passwd[new_password][second]' => '',
- ),
+ ],
'validator.password_must_match',
- ),
- array(
- array(
+ ],
+ [
+ [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'hop',
'change_passwd[new_password][second]' => 'hop',
- ),
+ ],
'validator.password_too_short',
- ),
- );
+ ],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
$form = $crawler->filter('button[id=change_passwd_save]')->form();
- $data = array(
+ $data = [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'mypassword',
'change_passwd[new_password][second]' => 'mypassword',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.password_updated', $alert[0]);
}
public function dataForUserFailed()
{
- return array(
- array(
- array(
+ return [
+ [
+ [
'update_user[name]' => '',
'update_user[email]' => '',
- ),
+ ],
'fos_user.email.blank',
- ),
- array(
- array(
+ ],
+ [
+ [
'update_user[name]' => '',
'update_user[email]' => 'test',
- ),
+ ],
'fos_user.email.invalid',
- ),
- );
+ ],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
$form = $crawler->filter('button[id=update_user_save]')->form();
- $data = array(
+ $data = [
'update_user[name]' => 'new name',
'update_user[email]' => 'admin@wallabag.io',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.config.notice.user_updated', $alert[0]);
}
public function dataForNewUserFailed()
{
- return array(
- array(
- array(
+ return [
+ [
+ [
'new_user[username]' => '',
'new_user[plainPassword][first]' => '',
'new_user[plainPassword][second]' => '',
'new_user[email]' => '',
- ),
+ ],
'fos_user.username.blank',
- ),
- array(
- array(
+ ],
+ [
+ [
'new_user[username]' => 'a',
'new_user[plainPassword][first]' => 'mypassword',
'new_user[plainPassword][second]' => 'mypassword',
'new_user[email]' => '',
- ),
+ ],
'fos_user.username.short',
- ),
- array(
- array(
+ ],
+ [
+ [
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'mypassword',
'new_user[plainPassword][second]' => 'mypassword',
'new_user[email]' => 'test',
- ),
+ ],
'fos_user.email.invalid',
- ),
- array(
- array(
+ ],
+ [
+ [
'new_user[username]' => 'admin',
'new_user[plainPassword][first]' => 'wallacewallace',
'new_user[plainPassword][second]' => 'wallacewallace',
'new_user[email]' => 'wallace@wallace.me',
- ),
+ ],
'fos_user.username.already_used',
- ),
- array(
- array(
+ ],
+ [
+ [
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'mypassword1',
'new_user[plainPassword][second]' => 'mypassword2',
'new_user[email]' => 'wallace@wallace.me',
- ),
+ ],
'validator.password_must_match',
- ),
- );
+ ],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
$form = $crawler->filter('button[id=new_user_save]')->form();
- $data = array(
+ $data = [
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'wallace1',
'new_user[plainPassword][second]' => 'wallace1',
'new_user[email]' => 'wallace@wallace.me',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.user_added', $alert[0]);
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('config.form_rss.no_token', $body[0]);
$client->request('GET', '/generate-token');
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertNotContains('config.form_rss.no_token', $body[0]);
}
$client->request(
'GET',
'/generate-token',
- array(),
- array(),
- array('HTTP_X-Requested-With' => 'XMLHttpRequest')
+ [],
+ [],
+ ['HTTP_X-Requested-With' => 'XMLHttpRequest']
);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=rss_config_save]')->form();
- $data = array(
+ $data = [
'rss_config[rss_limit]' => 12,
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.rss_updated', $alert[0]);
}
public function dataForRssFailed()
{
- return array(
- array(
- array(
+ return [
+ [
+ [
'rss_config[rss_limit]' => 0,
- ),
+ ],
'This value should be 1 or more.',
- ),
- array(
- array(
+ ],
+ [
+ [
'rss_config[rss_limit]' => 1000000000000,
- ),
+ ],
'validator.rss_limit_too_hight',
- ),
- );
+ ],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
- $data = array(
+ $data = [
'tagging_rule[rule]' => 'readingTime <= 3',
'tagging_rule[tags]' => 'short reading',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.tagging_rules_updated', $alert[0]);
$deleteLink = $crawler->filter('.delete')->last()->link();
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.tagging_rules_deleted', $alert[0]);
}
public function dataForTaggingRuleFailed()
{
- return array(
- array(
- array(
+ return [
+ [
+ [
'tagging_rule[rule]' => 'unknownVar <= 3',
'tagging_rule[tags]' => 'cool tag',
- ),
- array(
+ ],
+ [
'The variable',
'does not exist.',
- ),
- ),
- array(
- array(
+ ],
+ ],
+ [
+ [
'tagging_rule[rule]' => 'length(domainName) <= 42',
'tagging_rule[tags]' => 'cool tag',
- ),
- array(
+ ],
+ [
'The operator',
'does not exist.',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
foreach ($messages as $message) {
$this->assertContains($message, $body[0]);
$crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
$form = $crawler->filter('button[id=change_passwd_save]')->form();
- $data = array(
+ $data = [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'mypassword',
'change_passwd[new_password][second]' => 'mypassword',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('quickstart.intro.paragraph_1', $body[0]);
// Test if quickstart is disabled when user has 1 entry
$form = $crawler->filter('form[name=entry]')->form();
- $data = array(
+ $data = [
'entry[url]' => $this->url,
- );
+ ];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/unread/list');
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('entry.list.number_on_the_page', $body[0]);
}
$this->assertCount(4, $crawler->filter('div[class=entry]'));
// Good URL
- $client->request('GET', '/bookmarklet', array('url' => $this->url));
+ $client->request('GET', '/bookmarklet', ['url' => $this->url]);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/');
$crawler = $client->submit($form);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text')));
+ $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
$this->assertEquals('This value should not be blank.', $alert[0]);
}
$form = $crawler->filter('form[name=entry]')->form();
- $data = array(
+ $data = [
'entry[url]' => $this->url,
- );
+ ];
$client->submit($form, $data);
$form = $crawler->filter('form[name=entry]')->form();
- $data = array(
+ $data = [
'entry[url]' => $this->url,
- );
+ ];
$client->submit($form, $data);
$form = $crawler->filter('form[name=entry]')->form();
- $data = array(
+ $data = [
'entry[url]' => $url = 'https://github.com/wallabag/wallabag',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->request('GET', '/view/'.$content->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains($content->getTitle(), $body[0]);
}
$form = $crawler->filter('button[type=submit]')->form();
- $data = array(
+ $data = [
'entry[title]' => 'My updated title hehe :)',
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(array('_text')));
+ $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text']));
$this->assertContains('My updated title hehe :)', $alert[0]);
}
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[readingTime][right_number]' => 11,
'entry_filter[readingTime][left_number]' => 11,
- );
+ ];
$crawler = $client->submit($form, $data);
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
- $data = array(
+ $data = [
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
'entry_filter[createdAt][right_date]' => date('d/m/Y'),
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
- $data = array(
+ $data = [
'entry_filter[createdAt][left_date]' => '01/01/1970',
'entry_filter[createdAt][right_date]' => '01/01/1970',
- );
+ ];
$crawler = $client->submit($form, $data);
$form = $crawler->filter('button[id=config_save]')->form();
- $data = array(
+ $data = [
'config[items_per_page]' => '1',
- );
+ ];
$client->submit($form, $data);
// reset pagination
$crawler = $client->request('GET', '/config');
$form = $crawler->filter('button[id=config_save]')->form();
- $data = array(
+ $data = [
'config[items_per_page]' => '12',
- );
+ ];
$client->submit($form, $data);
}
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[domainName]' => 'domain',
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[domainName]' => 'wallabag',
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(0, $crawler->filter('div[class=entry]'));
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[language]' => 'fr',
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
- $data = array(
+ $data = [
'entry_filter[language]' => 'en',
- );
+ ];
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));
public function dataForBadUrl()
{
- return array(
- array(
+ return [
+ [
'/admin/YZIOAUZIAO/unread.xml',
- ),
- array(
+ ],
+ [
'/wallace/YZIOAUZIAO/starred.xml',
- ),
- array(
+ ],
+ [
'/wallace/YZIOAUZIAO/archives.xml',
- ),
- );
+ ],
+ ];
}
/**
$client->followRedirects();
$crawler = $client->request('GET', '/config');
- $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(array('_text'))[0]);
+ $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
}
public function testLoginWith2Factor()
$this->logInAs('admin');
$crawler = $client->request('GET', '/config');
- $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(array('_text'))[0]);
+ $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
// restore user
$user = $em
$form = $crawler->filter('form[name=tag]')->form();
- $data = array(
+ $data = [
'tag[label]' => $this->tagName,
- );
+ ];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals(1, count($newEntry->getTags()));
# tag already exists but still not assigned to this entry
- $data = array(
+ $data = [
'tag[label]' => 'foo',
- );
+ ];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=tag]')->form();
- $data = array(
+ $data = [
'tag[label]' => 'foo2, bar2',
- );
+ ];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
public function transformProvider()
{
- return array(
- array(null, ''),
- array(array(), ''),
- array(array('single value'), 'single value'),
- array(array('first value', 'second value'), 'first value,second value'),
- );
+ return [
+ [null, ''],
+ [[], ''],
+ [['single value'], 'single value'],
+ [['first value', 'second value'], 'first value,second value'],
+ ];
}
/**
public function reverseTransformProvider()
{
- return array(
- array(null, null),
- array('', array()),
- array('single value', array('single value')),
- array('first value,second value', array('first value', 'second value')),
- array('first value, second value', array('first value', 'second value')),
- array('first value, , second value', array('first value', 'second value')),
- );
+ return [
+ [null, null],
+ ['', []],
+ ['single value', ['single value']],
+ ['first value,second value', ['first value', 'second value']],
+ ['first value, second value', ['first value', 'second value']],
+ ['first value, , second value', ['first value', 'second value']],
+ ];
}
}
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
- ->setMethods(array('fetchContent'))
+ ->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
- ->willReturn(array(
+ ->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
- ));
+ ]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80');
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
- ->setMethods(array('fetchContent'))
+ ->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
- ->willReturn(array(
+ ->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
- ));
+ ]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
- ->setMethods(array('fetchContent'))
+ ->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
- ->willReturn(array(
+ ->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
- 'open_graph' => array(
+ 'open_graph' => [
'og_title' => 'my title',
'og_description' => 'desc',
- ),
- ));
+ ],
+ ]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
- ->setMethods(array('fetchContent'))
+ ->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
- ->willReturn(array(
+ ->willReturn([
'html' => str_repeat('this is my content', 325),
'title' => 'this is my title',
'url' => 'http://1.1.1.1',
'content_type' => 'text/html',
'language' => 'fr',
- 'open_graph' => array(
+ 'open_graph' => [
'og_title' => 'my OG title',
'og_description' => 'OG desc',
'og_image' => 'http://3.3.3.3/cover.jpg',
- ),
- ));
+ ],
+ ]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
$entry = new Entry(new User());
- $proxy->assignTagsToEntry($entry, array(' tag1', 'tag2 '));
+ $proxy->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
$this->assertCount(2, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
$entry = new Entry(new User());
- $proxy->assignTagsToEntry($entry, array());
+ $proxy->assignTagsToEntry($entry, []);
$this->assertCount(0, $entry->getTags());
}
private function getTaggerMock()
{
return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger')
- ->setMethods(array('tag'))
+ ->setMethods(['tag'])
->disableOriginalConstructor()
->getMock();
}
public function testTagWithNoMatchingRule()
{
- $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
+ $taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
public function testTagWithAMatchingRule()
{
- $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
+ $taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
public function testTagWithAMixOfMatchingRules()
{
- $taggingRule = $this->getTaggingRule('bla bla', array('hey'));
- $otherTaggingRule = $this->getTaggingRule('rule as string', array('foo'));
+ $taggingRule = $this->getTaggingRule('bla bla', ['hey']);
+ $otherTaggingRule = $this->getTaggingRule('rule as string', ['foo']);
$user = $this->getUser([$taggingRule, $otherTaggingRule]);
$entry = new Entry($user);
public function testWhenTheTagExists()
{
- $taggingRule = $this->getTaggingRule('rule as string', array('foo'));
+ $taggingRule = $this->getTaggingRule('rule as string', ['foo']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
$tag = new Tag();
public function testSameTagWithDifferentfMatchingRules()
{
- $taggingRule = $this->getTaggingRule('bla bla', array('hey'));
- $otherTaggingRule = $this->getTaggingRule('rule as string', array('hey'));
+ $taggingRule = $this->getTaggingRule('bla bla', ['hey']);
+ $otherTaggingRule = $this->getTaggingRule('rule as string', ['hey']);
$user = $this->getUser([$taggingRule, $otherTaggingRule]);
$entry = new Entry($user);
public function testTagAllEntriesForAUser()
{
- $taggingRule = $this->getTaggingRule('bla bla', array('hey'));
+ $taggingRule = $this->getTaggingRule('bla bla', ['hey']);
$user = $this->getUser([$taggingRule]);
$this->rulerz
->method('filter')
- ->willReturn(array(new Entry($user), new Entry($user)));
+ ->willReturn([new Entry($user), new Entry($user)]);
$entries = $this->tagger->tagAllForUser($user);
*/
class InstallCommandMock extends InstallCommand
{
- protected function runCommand($command, $parameters = array())
+ protected function runCommand($command, $parameters = [])
{
return $this;
}
{
public function testSupportsWithNoRegistry()
{
- $params = new ParamConverter(array());
+ $params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter();
$this->assertFalse($converter->supports($params));
$registry->expects($this->once())
->method('getManagers')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
- $params = new ParamConverter(array());
+ $params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
$registry->expects($this->once())
->method('getManagers')
- ->will($this->returnValue(array('default' => null)));
+ ->will($this->returnValue(['default' => null]));
- $params = new ParamConverter(array());
+ $params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
$registry->expects($this->once())
->method('getManagers')
- ->will($this->returnValue(array('default' => null)));
+ ->will($this->returnValue(['default' => null]));
$registry->expects($this->once())
->method('getManagerForClass')
->with('superclass')
->will($this->returnValue($em));
- $params = new ParamConverter(array('class' => 'superclass'));
+ $params = new ParamConverter(['class' => 'superclass']);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
$registry->expects($this->once())
->method('getManagers')
- ->will($this->returnValue(array('default' => null)));
+ ->will($this->returnValue(['default' => null]));
$registry->expects($this->once())
->method('getManagerForClass')
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
- $params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
+ $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
$converter = new UsernameRssTokenConverter($registry);
$this->assertTrue($converter->supports($params));
*/
public function testApplyEmptyRequest()
{
- $params = new ParamConverter(array());
+ $params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter();
$converter->apply(new Request(), $params);
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
- $params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
+ $params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
$converter = new UsernameRssTokenConverter($registry);
- $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
+ $request = new Request([], [], ['username' => 'test', 'token' => 'test']);
$converter->apply($request, $params);
}
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
- $params = new ParamConverter(array('class' => 'WallabagUserBundle:User', 'name' => 'user'));
+ $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']);
$converter = new UsernameRssTokenConverter($registry);
- $request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
+ $request = new Request([], [], ['username' => 'test', 'token' => 'test']);
$converter->apply($request, $params);
{
public function dataForPrefix()
{
- return array(
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
-
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
- array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
-
- array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
- array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
- array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
-
- array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
- array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
- array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
- );
+ return [
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
+
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
+ ['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
+
+ ['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
+ ['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
+ ['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
+
+ ['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
+ ['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
+ ['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
+ ];
}
/**
$subscriber = new TablePrefixSubscriber($prefix);
$metaClass = new ClassMetadata($entityName);
- $metaClass->setPrimaryTable(array('name' => $tableName));
+ $metaClass->setPrimaryTable(['name' => $tableName]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
->getMock();
$metaClass = new ClassMetadata($entityName);
- $metaClass->setPrimaryTable(array('name' => $tableName));
+ $metaClass->setPrimaryTable(['name' => $tableName]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
$subscriber = new TablePrefixSubscriber('yo_');
$metaClass = new ClassMetadata('Wallabag\UserBundle\Entity\Entry');
- $metaClass->setPrimaryTable(array('name' => 'entry'));
- $metaClass->mapManyToMany(array(
+ $metaClass->setPrimaryTable(['name' => 'entry']);
+ $metaClass->mapManyToMany([
'fieldName' => 'tags',
- 'joinTable' => array('name' => null, 'schema' => null),
+ 'joinTable' => ['name' => null, 'schema' => null],
'targetEntity' => 'Tag',
'mappedBy' => null,
'inversedBy' => 'entries',
- 'cascade' => array('persist'),
+ 'cascade' => ['persist'],
'indexBy' => null,
'orphanRemoval' => false,
'fetch' => 2,
- ));
+ ]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
{
$crawler = $this->client->request('GET', '/login');
$form = $crawler->filter('button[type=submit]')->form();
- $data = array(
+ $data = [
'_username' => $username,
'_password' => 'mypassword',
- );
+ ];
$this->client->submit($form, $data);
}
$token = substr(base64_encode(random_bytes($length)), 0, $length);
// remove character which can broken the url
- return str_replace(array('+', '/'), '', $token);
+ return str_replace(['+', '/'], '', $token);
}
/**
{
public function getFilters()
{
- return array(
- new \Twig_SimpleFilter('removeWww', array($this, 'removeWww')),
- );
+ return [
+ new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
+ ];
}
public function removeWww($url)
{
$pocket = $this->get('wallabag_import.pocket.import');
$form = $this->createFormBuilder($pocket)
- ->add('mark_as_read', CheckboxType::class, array(
+ ->add('mark_as_read', CheckboxType::class, [
'label' => 'import.form.mark_as_read_label',
'required' => false,
- ))
+ ])
->getForm();
return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
public function authAction(Request $request)
{
$requestToken = $this->get('wallabag_import.pocket.import')
- ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL));
+ ->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
if (false === $requestToken) {
$this->get('session')->getFlashBag()->add(
$this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
return $this->redirect(
- 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL),
+ 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
301
);
}
if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
$summary = $pocket->getSummary();
- $message = $this->get('translator')->trans('flashes.import.notice.summary', array(
+ $message = $this->get('translator')->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
- ));
+ ]);
}
$this->get('session')->getFlashBag()->add(
if (true === $res) {
$summary = $wallabag->getSummary();
- $message = $this->get('translator')->trans('flashes.import.notice.summary', array(
+ $message = $this->get('translator')->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
- ));
+ ]);
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('file', FileType::class, array(
+ ->add('file', FileType::class, [
'label' => 'import.form.file_label',
- ))
- ->add('mark_as_read', CheckboxType::class, array(
+ ])
+ ->add('mark_as_read', CheckboxType::class, [
'label' => 'import.form.mark_as_read_label',
'required' => false,
- ))
- ->add('save', SubmitType::class, array(
+ ])
+ ->add('save', SubmitType::class, [
'label' => 'import.form.save_label',
- ))
+ ])
;
}
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
- $data = array(
+ $data = [
'upload_import_file[file]' => $file,
- );
+ ];
$client->submit($form, $data);
$this->assertTrue($content->getTags()->contains($tag));
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
}
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json');
- $data = array(
+ $data = [
'upload_import_file[file]' => $file,
'upload_import_file[mark_as_read]' => 1,
- );
+ ];
$client->submit($form, $data);
$this->assertTrue($content2->isArchived());
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
}
$file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
- $data = array(
+ $data = [
'upload_import_file[file]' => $file,
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.failed', $body[0]);
}
}
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
- $data = array(
+ $data = [
'upload_import_file[file]' => $file,
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
$content = $client->getContainer()
$file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
- $data = array(
+ $data = [
'upload_import_file[file]' => $file,
- );
+ ];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.failed', $body[0]);
}
}
$container
->register('foo')
- ->addTag('wallabag_import.import', array('alias' => 'pocket'))
+ ->addTag('wallabag_import.import', ['alias' => 'pocket'])
;
$this->process($container);
);
$this->logHandler = new TestHandler();
- $logger = new Logger('test', array($this->logHandler));
+ $logger = new Logger('test', [$this->logHandler]);
$pocket->setLogger($logger);
return $pocket;
$wallabag = new WallabagV1Import($this->em, $this->contentProxy);
$this->logHandler = new TestHandler();
- $logger = new Logger('test', array($this->logHandler));
+ $logger = new Logger('test', [$this->logHandler]);
$wallabag->setLogger($logger);
if (false === $unsetUser) {
$wallabag = new WallabagV2Import($this->em, $this->contentProxy);
$this->logHandler = new TestHandler();
- $logger = new Logger('test', array($this->logHandler));
+ $logger = new Logger('test', [$this->logHandler]);
$wallabag->setLogger($logger);
if (false === $unsetUser) {
{
parent::__construct();
$this->entries = new ArrayCollection();
- $this->roles = array('ROLE_USER');
+ $this->roles = ['ROLE_USER'];
}
/**
*/
public static function getSubscribedEvents()
{
- return array(
+ return [
FOSUserEvents::RESETTING_RESET_SUCCESS => 'onPasswordResettingSuccess',
- );
+ ];
}
public function onPasswordResettingSuccess(FormEvent $event)
{
$template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig');
- $subject = $template->renderBlock('subject', array());
+ $subject = $template->renderBlock('subject', []);
$bodyHtml = $template->renderBlock('body_html', [
'user' => $user->getName(),
'code' => $user->getEmailAuthCode(),
{% block body_text %}text body {{ support_url }}{% endblock %}
TWIG;
- $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate)));
+ $this->twig = new \Twig_Environment(new \Twig_Loader_Array(['WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate]));
$this->config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config')
->disableOriginalConstructor()
$msg = $this->spool->getMessages()[0];
$this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
- $this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom());
+ $this->assertEquals(['nobody@test.io' => 'wallabag test'], $msg->getFrom());
$this->assertEquals('subject', $msg->getSubject());
$this->assertContains('text body http://0.0.0.0/support', $msg->toString());
$this->assertContains('html body 666666', $msg->toString());