Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Buidling

Bruno Škvorc Swader

🏠
Buidling
View GitHub Profile
@Swader
Swader / Test
Created Apr 19, 2012
Trying out cocode.io
View Test
namespace cocode;
class Cocode {
private $_sMsg;
public function __construct($sMsg = '') {
if (!empty($sMsg)) {
$this->setMessage($sMsg);
}
}
@Swader
Swader / zf2selectDemo.php
Created Sep 10, 2012
ZF2 : Populating a select element
View zf2selectDemo.php
// 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 Sep 12, 2012
Fetching roles for a user
View staffhander1.php
// 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'));
View searchFunctionRules.php
/**
* 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 Sep 13, 2012
Contact Search Form
View ContactSearch.php
<?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 Sep 13, 2012
Rendering the Contacts Search Form
View renderSearchForm.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 / listMethod-Contacts.php
Created Sep 13, 2012
Contacts List Function
View listMethod-Contacts.php
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
View listContactsView.phtml
<?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);
View newComponentsSuggestion.php
<?php
/**
* Class User.php
*
* @category
* @package
* @license BSD License
* @version 0.01
* @since 2012-09-13
@Swader
Swader / ResultUsage.php
Created Sep 13, 2012
Usage example of the Result class
View ResultUsage.php
/**
* 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
}