Skip to content

Instantly share code, notes, and snippets.

View Swader's full-sized avatar
🏠
Buidling

Bruno Škvorc Swader

🏠
Buidling
View GitHub Profile
@Swader
Swader / Test
Created April 19, 2012 17:33
Trying out cocode.io
namespace cocode;
class Cocode {
private $_sMsg;
public function __construct($sMsg = '') {
if (!empty($sMsg)) {
$this->setMessage($sMsg);
}
}
@Swader
Swader / zf2selectDemo.php
Created September 10, 2012 16:44
ZF2 : Populating a select element
// Using Zend\Select form element
$oSelect = new Select('someName');
$oSelect->setAttribute('id', 'mySelect')->setLabel('This is a select box');
$aData = array(
'Option 1' => 'value1',
'Option 2' => 'value2',
array('label' => 'Option 3', 'selected' => true, 'value' => 'value3') // For default selection
);
@Swader
Swader / staffhander1.php
Created September 12, 2012 09:55
Fetching roles for a user
// Use case for StaffHandler -> fetching roles for a user
/* This is only valid if you're doing it
* in the IntechController - and ONLY if you have previously
* defined $this->oRegistry as
* $this->oRegistry = $this->getRegistry();
*/
$oStaffHandler = new StaffHandler($this->oRegistry->get('StaffMapper'));
@Swader
Swader / searchFunctionRules.php
Created September 13, 2012 00:37
Search Function Rules
/**
* Search methods MUST return an array with "rowCount" and "rowSet".
*
* Search methods build queries with provided params (filters) and
* options (display filters - page, items per page, etc. Search
* methods can then use the buildAndReturnMySQL method from the
* Database/Abstract, or they can return their own result set. The
* only important thing is that they always return a single array
* which contains "rowCount" and "rowSet" - this is very important for
* pagination.
@Swader
Swader / ContactSearch.php
Created September 13, 2012 00:42
Contact Search Form
<?php
/**
* To build a search form, extend the BackendExtendedSearchForm
*
* Then, just add some more elements into it, like in the example below.
* When you add the elements, don't forget to render them in the view, and
* fetch them in the controller when the form is submitted.
*
* You can also write a form manually, but make sure you give it the class
@Swader
Swader / renderSearchForm.php
Created September 13, 2012 00:45
Rendering the Contacts Search Form
$this->searchForm->prepare();
echo $this->form()->openTag($this->searchForm);
echo $this->formRow($this->searchForm->get('validity'));
echo $this->formRow($this->searchForm->get('deleted'));
echo $this->formRow($this->searchForm->get('activated'));
echo $this->formInput($this->searchForm->get('search'));
echo $this->formRow($this->searchForm->get('submit'));
echo $this->form()->closeTag($this->searchForm);
@Swader
Swader / listMethod-Contacts.php
Created September 13, 2012 00:47
Contacts List Function
public function listAction()
{
$oPagination = null;
$oSearchForm = new \Manager\Form\ContactSearch();
$oSearchForm->setAttribute('action', '/manager/contacts/list');
$oSearchForm->setData($_GET);
$bSearchMode = false;
// Display the search toolbar
@Swader
Swader / listContactsView.phtml
Created September 13, 2012 00:50
Contacts List View
<?php
$this->searchForm->prepare();
echo $this->form()->openTag($this->searchForm);
echo $this->formRow($this->searchForm->get('validity'));
echo $this->formRow($this->searchForm->get('deleted'));
echo $this->formRow($this->searchForm->get('activated'));
echo $this->formInput($this->searchForm->get('search'));
echo $this->formRow($this->searchForm->get('submit'));
echo $this->form()->closeTag($this->searchForm);
@Swader
Swader / newComponentsSuggestion.php
Created September 13, 2012 14:50
User suggestion
<?php
/**
* Class User.php
*
* @category
* @package
* @license BSD License
* @version 0.01
* @since 2012-09-13
@Swader
Swader / ResultUsage.php
Created September 13, 2012 19:00
Usage example of the Result class
/**
* The Result class is the default return format of the APIs
*
* When you get a Result object (e.g. $r), the recommended way of checking
* whether or not it contains any values is like so:
*/
if ($r->count()) {
// Do something
}