Skip to content

Instantly share code, notes, and snippets.

View johnhamelink's full-sized avatar
🔨
Building

John Hamelink johnhamelink

🔨
Building
View GitHub Profile
$history = new EventHistory();
$backlog = $history->getHistory();
$result = [];
foreach($backlog as $k => $log) {
$result[$k] = new stdClass();
$result[$k]->date = $log->get('updatedAt')->format('d-m-Y');
$result[$k]->time = $log->get('updatedAt')->format('h:ia');
var_dump($log->get('staff'));
//$result[$k]->staff = $log->get('staff')->get('nickName');
<?php
/**
* Output filtered event history
*/
class EventHistory {
protected $em;
public function __construct() {
<?php
/*
* Copyright (c) 2012, John Hamelink
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
<?php
class Ajax_Staff_Controller extends Base_Controller {
private $em;
public function __construct() {
$this->em = EntityManager::getInstance();
}
// Get the company repository
$repo = EntityManager::getInstance()->getRepository('company');
// For each row we need to insert
foreach ($this->input as $row) {
// Find a company
$company = $repo->findOneBy(['ticker' => $row['Ticker']]);
if ($company == null) {
$warnings[] = $row['Ticker'] . ' could not be found in the database';
continue;
public function addToDB() {
$warnings = [];
// Get the company repository
$repo = EntityManager::getInstance()->getRepository('company');
// For each row we need to insert
foreach ($this->input as $row) {
// Find a company
$company = $repo->findOneBy(['ticker' => $row['Ticker']]);
if ($company == null) {
$em = EntityManager::getInstance();
$company = $em->getRepository('company')->findOne('4FB24C10D54E845C0400001D');
die();
<?php
/**
* The company custom Repository holds
* convenience methods for generating
* common formulae using data in the database
*
* <code>
* $em->getCompanyById($id)->getEnterpriseValue();
* </code>
<?php
/**
* The company custom Repository holds
* convenience methods for generating
* common formulae using data in the database
*
* <code>
* $em->getCompanyById($id)->getEnterpriseValue();
* </code>
$em = EntityManager::getInstance();
$company = $em->getRepository('company')->findOne('4FB24C10D54E845C0400001D');
echo "<pre>";
print_r($company->loadCustomMethods('companyy')->priceToEarningsRatio());
die();