Created
June 25, 2013 13:17
-
-
Save tawfekov/5858354 to your computer and use it in GitHub Desktop.
ZF2 application with Symfony Console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/* | |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
* | |
* This software consists of voluntary contributions made by many individuals | |
* and is licensed under the MIT license. For more information, see | |
* <http://www.doctrine-project.org>. | |
*/ | |
use Zend\Mvc\Application; | |
use Symfony\Component\Console\Application as SymfonyApplication; | |
use Adsl\Service\Task\Command\Sms; | |
use Adsl\Service\Task\Command\Email ; | |
use Adsl\Service\Task\Command\Remote; | |
use Adsl\Service\Task\Command\Pdf; | |
ini_set('display_errors', true); | |
error_reporting(E_ALL); | |
chdir(__DIR__); | |
$previousDir = '.'; | |
while (!file_exists('config/application.config.php')) { | |
$dir = dirname(getcwd()); | |
if ($previousDir === $dir) { | |
throw new RuntimeException( | |
'Unable to locate "config/application.config.php": ' . | |
'is DoctrineModule in a subdir of your application skeleton?' | |
); | |
} | |
$previousDir = $dir; | |
chdir($dir); | |
} | |
if (!(@include_once __DIR__ . '/../vendor/autoload.php') && !(@include_once __DIR__ . '/../../../autoload.php')) { | |
throw new RuntimeException('Error: vendor/autoload.php could not be found. Did you run php composer.phar install?'); | |
} | |
$application = Application::init(include 'config/application.config.php'); | |
$sm = $application->getServiceManager(); | |
$em = $sm->get("doctrine.entitymanager.orm_default"); | |
$user = $em->getRepository("Adsl\Entity\User")->find(1); | |
$auditConfig = $sm->get("auditConfig"); | |
$auditConfig->setCurrentUser($user); | |
$manager = new \Adsl\Service\Task\Manager(); | |
$manager->setEntityManager($em); | |
$manager->setServiceLocator($sm); | |
$console = new SymfonyApplication(); | |
/// sms commands | |
$console->add(new Sms\All($manager)); | |
$console->add(new Sms\Id($manager)); | |
/// emails commands | |
$console->add(new Email\Report($manager)); | |
$console->add(new Email\Weekly($manager)); | |
$console->add(new Email\Editpayment($manager , $sm)); | |
/// remote commands | |
$console->add(new Remote\Check()); | |
$console->add(new Remote\Create($manager)); | |
$console->add(new Remote\Read($manager)); | |
$console->add(new Remote\BulkRead($manager)); | |
$console->add(new Remote\RunAll($manager)); | |
$console->add(new Remote\Import($manager)); | |
$console->add(new Remote\UpdateSpeed($manager)); | |
/// pdf command | |
$console->add(new Pdf\Cancel($manager)); | |
$console->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment