/** * Displays a form to create a new Job entity. * */ public function newAction() { $entity = new Job(); $entity->setType('full-time'); $form = $this->createForm(new JobType(), $entity); return $this->render('ErlemJobeetBundle:Job:new.html.twig', array('entity' => $entity, 'form' => $form->createView())); }
public function getForLuceneQuery($query) { $hits = Job::getLuceneIndex()->find($query); $pks = array(); foreach ($hits as $hit) { $pks[] = $hit->pk; } if (empty($pks)) { return array(); } $q = $this->createQueryBuilder('j')->where('j.id IN (:pks)')->setParameter('pks', $pks)->andWhere('j.is_activated = :active')->setParameter('active', 1)->setMaxResults(20)->getQuery(); return $q->getResult(); }
protected function execute(InputInterface $input, OutputInterface $output) { $days = $input->getArgument('days'); $em = $this->getContainer()->get('doctrine')->getManager(); // cleanup Lucene index $index = Job::getLuceneIndex(); $q = $em->getRepository('ErlemJobeetBundle:Job')->createQueryBuilder('j')->where('j.expires_at < :date')->setParameter('date', date('Y-m-d'))->getQuery(); $jobs = $q->getResult(); foreach ($jobs as $job) { if ($hit = $index->find('pk:' . $job->getId())) { $index->delete($hit->id); } } $index->optimize(); $output->writeln('Cleaned up and optimized the job index'); // Remove stale jobs $nb = $em->getRepository('ErlemJobeetBundle:Job')->cleanup($days); $output->writeln(sprintf('Removed %d stale jobs', $nb)); }
public function testSetExpiresAtValue() { $job = new Job(); $job->setExpiresAtValue(); $this->assertEquals(time() + 86400 * 30, $job->getExpiresAt()->format('U')); }
public function testGetForLuceneQuery() { $em = static::$kernel->getContainer()->get('doctrine')->getManager(); $job = new Job(); $job->setType('part-time'); $job->setCompany('Sensio'); $job->setPosition('FOO6'); $job->setLocation('Paris'); $job->setDescription('WebDevelopment'); $job->setHowToApply('Send resumee'); $job->setEmail('jobeet[at]example.com'); $job->setUrl('http://sensio-labs.com'); $job->setIsActivated(false); $em->persist($job); $em->flush(); $jobs = $em->getRepository('ErlemJobeetBundle:Job')->getForLuceneQuery('FOO6'); $this->assertEquals(count($jobs), 0); $job = new Job(); $job->setType('part-time'); $job->setCompany('Sensio'); $job->setPosition('FOO7'); $job->setLocation('Paris'); $job->setDescription('WebDevelopment'); $job->setHowToApply('Send resumee'); $job->setEmail('jobeet[at]example.com'); $job->setUrl('http://sensio-labs.com'); $job->setIsActivated(true); $em->persist($job); $em->flush(); $jobs = $em->getRepository('ErlemJobeetBundle:Job')->getForLuceneQuery('position:FOO7'); $this->assertEquals(count($jobs), 1); foreach ($jobs as $job_rep) { $this->assertEquals($job_rep->getId(), $job->getId()); } $em->remove($job); $em->flush(); $jobs = $em->getRepository('ErlemJobeetBundle:Job')->getForLuceneQuery('position:FOO7'); $this->assertEquals(count($jobs), 0); }
public function load(ObjectManager $em) { $job_expired = new Job(); $job_expired->setCategory($em->merge($this->getReference('category-programming'))); $job_expired->setType('full-time'); $job_expired->setCompany('Sensio Labs'); $job_expired->setLogo('sensio-labs.gif'); $job_expired->setUrl('http://www.sensiolabs.com/'); $job_expired->setPosition('Web Developer Expired'); $job_expired->setLocation('Paris, France'); $job_expired->setDescription('Lorem ipsum dolor sit amet, consectetur adipisicing elit.'); $job_expired->setHowToApply('Send your resume to lorem.ipsum[at]dolor.sit'); $job_expired->setIsPublic(true); $job_expired->setIsActivated(true); $job_expired->setToken('job_expired'); $job_expired->setEmail('job[at]example.com'); $job_expired->setCreatedAt(new \DateTime('2005-12-01')); $job_sensio_labs = new Job(); $job_sensio_labs->setCategory($em->merge($this->getReference('category-programming'))); $job_sensio_labs->setType('full-time'); $job_sensio_labs->setCompany('Sensio Labs'); $job_sensio_labs->setLogo('sensio-labs.gif'); $job_sensio_labs->setUrl('http://www.sensiolabs.com/'); $job_sensio_labs->setPosition('Web Developer'); $job_sensio_labs->setLocation('Paris, France'); $job_sensio_labs->setDescription('You\'ve already developed websites with symfony and you want to work with Open-Source technologies. You have a minimum of 3 years experience in web development with PHP or Java and you wish to participate to development of Web 2.0 sites using the best frameworks available.'); $job_sensio_labs->setHowToApply('Send your resume to fabien.potencier[at]sensio.com'); $job_sensio_labs->setIsPublic(true); $job_sensio_labs->setIsActivated(true); $job_sensio_labs->setToken('job_sensio_labs'); $job_sensio_labs->setEmail('job[at]example.com'); $job_sensio_labs->setExpiresAt(new \DateTime('+30 days')); $job_extreme_sensio = new Job(); $job_extreme_sensio->setCategory($em->merge($this->getReference('category-design'))); $job_extreme_sensio->setType('part-time'); $job_extreme_sensio->setCompany('Extreme Sensio'); $job_extreme_sensio->setLogo('extreme-sensio.gif'); $job_extreme_sensio->setUrl('http://www.extreme-sensio.com/'); $job_extreme_sensio->setPosition('Web Designer'); $job_extreme_sensio->setLocation('Paris, France'); $job_extreme_sensio->setDescription('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in.'); $job_extreme_sensio->setHowToApply('Send your resume to fabien.potencier[at]sensio.com'); $job_extreme_sensio->setIsPublic(true); $job_extreme_sensio->setIsActivated(true); $job_extreme_sensio->setToken('job_extreme_sensio'); $job_extreme_sensio->setEmail('job[at]example.com'); $job_extreme_sensio->setExpiresAt(new \DateTime('+30 days')); for ($i = 100; $i <= 130; $i++) { $job = new Job(); $job->setCategory($em->merge($this->getReference('category-programming'))); $job->setType('full-time'); $job->setCompany('Company ' . $i); $job->setPosition('Web Developer'); $job->setLocation('Paris, France'); $job->setDescription('Lorem ipsum dolor sit amet, consectetur adipisicing elit.'); $job->setHowToApply('Send your resume to lorem.ipsum [at] dolor.sit'); $job->setIsPublic(true); $job->setIsActivated(true); $job->setToken('job_' . $i); $job->setEmail('job[at]example.com'); $em->persist($job); } $em->persist($job_sensio_labs); $em->persist($job_extreme_sensio); $em->persist($job_expired); $em->flush(); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('category')->add('type', 'choice', array('choices' => Job::getTypes(), 'expanded' => true))->add('company')->add('file', 'file', array('label' => 'Company logo', 'required' => false))->add('url')->add('position')->add('location')->add('description')->add('how_to_apply', null, array('label' => 'How to apply?'))->add('is_public', null, array('label' => 'Public?'))->add('email'); }
protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('category')->add('type', 'choice', array('choices' => Job::getTypes(), 'expanded' => true))->add('company')->add('file', 'file', array('label' => 'Company logo', 'required' => false))->add('url')->add('position')->add('location')->add('description')->add('how_to_apply')->add('is_public')->add('email')->add('is_activated'); }