Skip to content

Instantly share code, notes, and snippets.

View ppeiris's full-sized avatar
🏋️‍♂️
Working on machine learning projects

Prabath Peiris ppeiris

🏋️‍♂️
Working on machine learning projects
View GitHub Profile
<?php
namespace Zsend;
use Zsend\Listener;
use Zend\Mvc\MvcEvent;
class Module
{
public function getAutoloaderConfig()
{
/** Autoloading config */
@ppeiris
ppeiris / blog_composer1
Last active December 26, 2015 16:59
This is to display in blog www.ttiaf.com
{
"name": "Your Application Name",
"description": "Application Description",
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"repositories": [
{ "type": "composer",
"url": "https://packages.zendframework.com" }
],
"require": {
@ppeiris
ppeiris / blog_apiglityconfig.php
Last active December 26, 2015 17:18
This snippet display in my blog ttiaf.com
<?php
/**
* Activated modules.
*/
return array(
'modules' => array(
'....' // Your existing appication modules
'ZF\Apigility', // Apigility modules.
'AssetManager',
'ZF\ApiProblem',
<?php
return array(
'db' => array(
'driver' => 'Pdo',
'driver_options' => array(
1002 => 'SET NAMES \'UTF8\'',
),
'adapters' => array(
'Zdbtable' => array(),
),
private function setResetToken($accountid) {
try {
$token = uniqid().uniqid(); /** Generate a unique token */
$tAccounts = new \Entity\Tables\tAccounts();
$newReset = new \Entity\Tables\tAccountPasswordReset();
$newReset->setTAccount($tAccounts);
$newReset->accountId = $accountid;
$newReset->resetToken = $token;
$this->entityManager->persist($newReset);
$this->entityManager->flush();
<?php
namespace Entity\Tables;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
<?php
namespace Entity\Tables;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
class tAccountPasswordReset {
<?php
/** Create an object of tAccounts */
$account = $this->entityManager->getRepository('\Entity\Tables\tAccounts');
/** Find a record */
$record = $account->findOneBy(array('userEmail' => $email));
if ($record) {
/** get all the records in the tAccountPasswordReset table that link via foreign key (accountId) */
$resetRecords = $record->getPasswordResets();
}
<?php
$account = $this->entityManager->getRepository('\Entity\Tables\tAccounts');
/** Find the account from tAccounts table */
$record = $account->findOneBy(array('userEmail' => $email));
if ($record) { // There is an active account for given email.
/** Generate a unique token */
$token = uniqid().uniqid();
/** create a new tAccountPasswordReset object and fill the info */
$newReset = new \Entity\Tables\tAccountPasswordReset();
<?php
class yourclass implements ServiceLocatorAwareInterface
{
protected $serviceLocator;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;