$logWriter = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array('handlers' => array(new \Monolog\Handler\StreamHandler('src/log/' . date('Y-m-d') . '.log')))); //$logWriter = new \Slim\LogWriter(fopen('src/log/errors_slim.log', 'a')); //$logWriter = new \Slim\LogWriter(fopen('src/log/bullhorn.log', 'a')); $app = new \Slim\Slim(array('debug' => true, 'log.enabled' => true, 'log.level' => \Slim\Log::DEBUG, 'mode' => 'development', 'log.writer' => $logWriter, 'templates.path' => 'Stratum/templates')); $app->setName('stratum'); $log = $app->getLog(); $app->post('/endpoint/:id', function ($endpoint) use($log) { $entityBody = file_get_contents('php://input'); $log->debug($entityBody); $formController = new Stratum\Controller\FormController(); $log->debug("parsing input data"); $formResult = $formController->parse($entityBody); $formResult->setLogger($log); //form has updated mappings for each question $candidate = new Stratum\Model\Candidate(); $candidate->setLogger($log); $log->debug("parsed input data"); $candidateController = new Stratum\Controller\CandidateController(); $candidateController->setLogger($log); $candidate = $candidateController->populate($candidate, $formResult); $log->debug("Candidate submitted with name " . $candidate->getName()); $controller = new Stratum\Controller\BullhornController(); $controller->setLogger($log); $controller->submit($candidate); }); $app->get('/launch', function () use($app) { $app->redirect('http://northcreek.ca/stratum/launch.html'); }); $app->get('/launchForm', function (Request $request, Response $response) use($log) { // this is all the happy path assuming everything is set up properly from the Bullhorn side //load the id from the request
public function load(\Stratum\Model\Candidate $candidate) { $bullhornClient = $this->getClient(); $candidateController = new \Stratum\Controller\CandidateController(); $candidateController->setLogger($this->_logger); //load $candidate based on ID currently in $candidate $candidate = $bullhornClient->find($candidate); if ($candidate == null) { //error condition according to Stratum //re-initialize $candidate = new \Stratum\Model\Candidate(); $candidate->setLogger($this->_logger); } /** * debug only * if ($bullhornClient->confirm($candidate)) { $this->log_debug("<p>Success!</p>"); } else { $this->log_debug("Failure: please examine log files"); } **/ return $candidate; }
public function load(\Stratum\Model\Candidate $candidate) { $bullhornClient = $this->getClient(); $candidateController = new \Stratum\Controller\CandidateController(); $candidateController->setLogger($this->_logger); //load $candidate based on ID currently in $candidate $candidate = $bullhornClient->find($candidate); if ($candidate == null) { //error condition according to Stratum //re-initialize $candidate = new \Stratum\Model\Candidate(); $candidate->setLogger($this->_logger); } return $candidate; }