SlideShare une entreprise Scribd logo
1  sur  59
Télécharger pour lire hors ligne
ATK
                               beyond the Pizza Guides

                              Peter C. Verhage - 14th of May 2008




ATK beyond the Pizza Guides
Node


ATK beyond the Pizza Guides
Node
     • Action triggers:
         •    preAdd(&$record) / postAdd($record)

         •    preUpdate(&$record) / postUpdate($record)

         •    preDelete($record) / postDelete($record)

         •    preCopy(&$record)

     • Return false to abort action (auto rollback)
     • Most of the time implemented inside node
ATK beyond the Pizza Guides
Node
     • Implement triggers outside a node using a
          listener (registered using a modifier)
     • $node->addListener(...)
     • atkActionListener - deprecated
     • atkTriggerListener - allows you to
          implement all previously mentioned triggers
          inside your own external class with the
          same behavior
ATK beyond the Pizza Guides
Node

     • Less known flags:
         •    NF_TRACK_CHANGES - gives access to the original
              record for update actions ($record[‘atkorgrec’])

         •    NF_ADDAFTERADD - allows adding record after record

         •    NF_ADD_DIALOG - add new records inside a dialog

         •    NF_ADDORCOPY_DIALOG - shows a dialog when
              wanting to add a new record giving the user the choice to
              copy an existing record or add a new record


ATK beyond the Pizza Guides
Node
     • Misc. useful methods:
         •    $node->setDescriptorTemplate($template) - no need to
              implement descriptor_def anymore

         •    $node->preAddToEditArray(&$record, $mode) - allows you
              to do last minute modifications to attributes etc. just before
              a record is edited

         •    $node->text(...) - context aware translations

         •    $node->escapeSQL(...) - database aware escaping (knows
              the database your node uses)

ATK beyond the Pizza Guides
Meta Node


ATK beyond the Pizza Guides
Meta Node
     • Uses database metadata to detect:
         •
        table and sequence name
         •    attributes:
             •   name
             •   type (e.g. date → atkDateAttribute)
             •   flags (AF_OBLIGATORY, AF_PRIMARY...)
             •   order (in regard to other attributes)
             •   default value (limited!)

     • Only one extends atkMetaNode {}
       class Person
                    line of code needed:

ATK beyond the Pizza Guides
Meta Node
     • Options can be specified using:
         •
        protected class variables
         •    array in parent::__construct call (useful for base class!)

     • Options: name (“people”)
         •
        table - table
         •    sequence - sequence name (“seq_person”)
         •    db/database - database name (“default”)
         •    flags - node flags (NF_ADD_LINK etc.)
                     use an array for multiple flags!


ATK beyond the Pizza Guides
Meta Node

     • Options (continued): (“[name]”)
         •
        descriptor - descriptor template
         •    index - attribute name for index (“name”)
         •    securityAlias - security alias (“module.node”)
         •    securityMap - security map (array(“publish” => “edit”))

     • Be careful with inheritance!

ATK beyond the Pizza Guides
Meta Node
     • Implement metameta(atkMetaPolicy $policy)
       public static function
                              method for more control:

     • Allows full control over attributes and
          relations
     • Make sure it’s defined static to let the
          caching mechanism kick in!
     • Make full use of inheritance by calling
          parent::meta($policy)

ATK beyond the Pizza Guides
Meta Node

     • Control which columns to expose:
         •    $policy->setExcludes($attr1, $attr2, ...) - exclude
              certain attributes

         •    $policy->setIncludes($attr1, $attr2, ...) - only include
              the given attributes, implicitly sets the attribute order!

         •    $policy->remove($attr) - removes a single attribute




ATK beyond the Pizza Guides
Meta Node
     • Control attribute flags:
         •    $policy->addFlags($attr1, $attr2, ..., $flags) - add the
              given flag(s) for the given attributes

         •    $policy->removeFlags($attr1, $attr2, ..., $flags) -
              remove the given flags(s) for the given attributes

         •    $policy->setFlags($attr1, $attr2, ..., $flags) - explicitly
              set the flags for the given attributes (dangerous!)

         •    Alternatives:
              $policy->addFlag, $policy->removeFlag


ATK beyond the Pizza Guides
Meta Node
     • Control attribute tabs/sections:
         •    $policy->setSections($attr1, $attr2, ..., $sections) -
              sets the tabs/sections for the given attributes

         •    $sections can be either a single tab/section name or
              an array of tab/section names

         •    Format: <tab> or <tab>.<section>

         •    Previously set tabs/sections will be ignored!

         •    Alternatives:
              $policy->setSection, $policy->setTabs, $policy->setTab

ATK beyond the Pizza Guides
Meta Node
     • Forcing insertion/updates:
         •    $policy->addForceInsert($attr1, $attr2, ...) - set force
              insert to true for the given attributes

         •    $policy->removeForceInsert($attr1, $attr2, ...) - don’t
              force insertion of the given attributes

         •    $policy->addForceUpdate($attr1, $attr2, ...) - set force
              update to true for the given attributes

         •    $policy->removeForceUpdate($attr1, $attr2, ...) -
              don’t force update of the given attributes


ATK beyond the Pizza Guides
Meta Node
     • Changing attribute types and parameters:
         •    $policy->setType($attr, $type, $param1, ...) - sets the
              attribute type for the given attribute(s) and uses the
              given parameters when constructing the attribute

         •    $attr can be a single attribute name or an array

         •    $type can be anything that is valid for useattrib,
              userelation or atkimport (and knows about the node’s
              module)

         •    Parameters (optional) are passed as extra arguments


ATK beyond the Pizza Guides
Meta Node

     • Changing attribute types and parameters
          (alternative):
         •    $policy->setTypeAndParams($attr, $type, $params) -
              sets the attribute type for the given attribute(s) and
              uses the given parameters when constructing the
              attribute

         •    Same as $policy->setType, but parameters are passed
              as a single array and not as separate arguments



ATK beyond the Pizza Guides
Meta Node
     • Adding / overwriting attributes:
         •    $policy->add($name, $type [, $params [, $flags]])

         •    $type can be anything that is valid for useattrib,
              userelation or atkimport (and knows about the node’s
              module)

         •    $params should contain an array of attribute
              parameters (at least all mandatory parameters!)

         •    $flags should contain the attribute flags (int)

         •    Overwrite the current attribute entry (if applicable)!

ATK beyond the Pizza Guides
Meta Node

     • Many-to-one relation:
         •    $policy->hasOne($accessor)

         •    $accessor is the destination node

         •    Format: <module>.<node>

         •    If part of the same module, module can be ommitted

         •    Automatic translation from singular accessor names to
              plural node names (e.g. person → people)


ATK beyond the Pizza Guides
Meta Node
     • Many-to-one relation (continued...):
         •    Local attribute name is automatically detected (tries
              mutiple variants based on the destination node name
              and module name e.g. people_id, person_id, people,
              person etc.)

         •    $policy->hasOne($accessor, $descriptor)

         •    Descriptor can be specified as second parameter
              (overrides default descriptor in destination node)

         •    Format: “[name] ([city])”


ATK beyond the Pizza Guides
Meta Node
     • Many-to-one relation (continued...):
         •    $policy->hasOne($accessor, [$descriptor,] $options)

         •    Options can be specified as 2nd or 3rd argument
              (depending on whatever a descriptor is specified)

         •    Array containing the following options (all optional):

             •    source - local attribute name

             •    filter - destination where clause

             •    large - true/false, sets the AF_LARGE flag

ATK beyond the Pizza Guides
Meta Node
   • One-to-one relation
       •    $policy->hasOne($accessor [, $options])

       •    Uses same method as many-to-one relation

       •    Difference detected based on availability of local
            attribute (if not available → 1:1)

       •    Options:

           •    filter - destination where clause

           •    dest(-ination) - destination node attribute (forces 1:1)

ATK beyond the Pizza Guides
Meta Node

     • One-to-many relation:
         •    $policy->hasMany($accessor [, $options])

         •    $accessor is the destination node

         •    Format: <module>.<node>

         •    If part of the same module, module can be ommitted

         •    Automatic translation from plural accessor names to
              singular node names (e.g. people → person)


ATK beyond the Pizza Guides
Meta Node
     • One-to-many relation (continued...):
         •    Destination attribute name is automatically detected
              (tries mutiple variants based on the local node name
              and module name e.g. departments_id,
              department_id, departments, department etc.)

         •    Possible options ($options array):
             •    dest(-ination) - name of the attribute in the
                  destination node for this relation

             •    filter - destination node where clause

             •    name - local attribute name for relation

ATK beyond the Pizza Guides
Meta Node

     • Many-to-many relation:
         •    $policy->hasMany($accessor [, $descriptor], $options)

         •    Uses same method as one-to-many relation

         •    Descriptor is optional (if ommitted options need to be
              specified as second argument)

         •    Mandatory option “through” is used to detect that this
              is a many-to-many relation and should contain an
              accessor name for the link node


ATK beyond the Pizza Guides
Meta Node
     • Many-to-many relation (continued...):
         •    Example: $policy->hasMany(“people”,
              array(“through” => “department_person”))

         •    Other options:

             •    type - display type: shuttle (default), bool(-ean), list,
                  select, eshuttle (extended shuttle)

             •    local / remote - link node local / remote key

             •    filter - destination node where clause

             •    type specific options (cols/columns, rows)

ATK beyond the Pizza Guides
Meta Node

     • Misc. methods:
         •    $policy->setOrder($attr1, $attr2, ...) - sets the order
              of the attributes, all attributes not mentioned will keep
              their current order but are placed after the explicitly
              mentioned attributes

         •    $policy->setDefaultValue($attr1, $attr2, ..., $value) -
              sets the initial value for the given attributes

         •    $policy->text($string) - same as atktext but keeps
              module and node type into account


ATK beyond the Pizza Guides
Meta Node

     • More control needed?
     • public function postMeta()
     • Called after node has been configured and
          attributes/relations have been added
     • Early enough to do some more
          customizations


ATK beyond the Pizza Guides
Meta Node
     • Configuration options:
         •    $config_meta_caching - controls whatever generated
              code for meta nodes should be cached or not, turn of
              during development!

         •    $config_meta_policy - can be used to set an
              application wide alternative for the default policy class

         •    $config_meta_compiler - allows customization of the
              meta policy compiler (only useful in rare cases)

         •    $config_meta_grammar - allows customization of the
              singular / plural grammar rules (person → people)

ATK beyond the Pizza Guides
Meta Policy


ATK beyond the Pizza Guides
Meta Policy
     • Responsible for detecting the defaults for a
          meta node (table, attributes etc.)
     • Can be subclassed for supporting your own
          set of rules
     • Use $config_meta_policy to set an
          application wide policy
     • Can be specified per node using the
          $metaPolicy option (or in base class!)
ATK beyond the Pizza Guides
Meta Policy
     • Customizable methods:
         •    _getTypeAndParams($name, $meta) - should return
              an array with key “type” and “params” containing the
              attribute type and array of parameters

         •    _getFlags($name, $meta) - should return the attribute
              flags (int)

         •    _getOrder($name, $meta) - should return the order
              (index) for the attribute

         •    _getDefaultValue($name, $meta) - should return the
              default value for the attribute

ATK beyond the Pizza Guides
Meta Policy

     • Customizable methods (continued...):
         •    $name contains the column name

         •    $meta contains the column metadata and consists of:

             •    gentype - generic data type

             •    num - column index

             •    flags - flags; MF_PRIMARY, MF_NOT_NULL etc.

             •    default - detected default value


ATK beyond the Pizza Guides
Attributes and relations


ATK beyond the Pizza Guides
Attributes and relations
     • ATK contains:
         •    More than 50 attributes

         •    More than 10 relations

         •    Still growing each day

     • Luckily they are pretty well named :)
     • Some highlights of less known attributes,
          relations and features you probably don’t
          know about
ATK beyond the Pizza Guides
Attributes and relations
     • Tracking of modifications; who / when
     • Attributes:
         •
         atkCreatedByAttribute - added by user ...
         •    atkCreateStampAttribute - created at
         •    atkUpdatedByAttribute - last updated by user ...
         •    atkUpdateStampAttribute - last updated at

     • Automatically used by meta node for fields
          with correct type and name:
          created_by, created_at, updated_by, updated_at

ATK beyond the Pizza Guides
Attributes and relations

     • atkExpressionAttribute
     • Custom expressions in select statement
     • Anything that is allowed by the database
          (subqueries, function calls etc.)
     • Even supports sorting and limited searching

ATK beyond the Pizza Guides
Attributes and relations
     • atkTabbedPane
     • Allows you to created nested tabs
     • Simply name the attributes you want to
          show on each tab
     • Attributes are automatically “removed”
          from their normal position
     • Use carefully (keep interface simple!)
ATK beyond the Pizza Guides
Attributes and relations

     • atkRadioDetailsAttribute
     • Allows you to show detail selections based
          on radio button selections
     • Works similar to atkTabbedPane
     • Still has some rough edges but will be
          improved in the near future


ATK beyond the Pizza Guides
Attributes and relations
     • Many many-to-many relations:
         •    atkManyBoolRelation - checkboxes

         •    atkShuttleRelation - move items between two lists

         •    atkExtendableShuttleRelation - allows filtering of
              shuttle lists (will eventually supersede
              atkShuttleRelation)

         •    atkManyToManySelectRelation - multi select list

         •    atkManyToManyListRelation - add items one by one
              using auto-completion or drop-down

ATK beyond the Pizza Guides
Attributes and relations
     • atkManyToOneRelation auto-completion
     •    AF_MANYTOONE_AUTOCOMPLETE

     • Many options:
         •
        $rel->setAutoCompleteMinRecords($recs)
         •    $rel->setAutoCompleteCaseSensitive($value)
         •    $rel->setAutoCompleteSearchFields($fields)
         •    $rel->setAutoCompleteSearchMode($mode)
              (exact, startswith, contains)

     • By default searches descriptor fields
ATK beyond the Pizza Guides
Attributes and relations
     • Showing more than one column for an
          atkManyToOneRelation in list view
     • $rel->addListColumn($col) or
          $rel->addListColumns($col1, $col2, ...)
     • Allows full sorting and searching
     • Only want to show extra columns?
         •
         AF_HIDE_LIST
         •    $rel->setAlwaysShowListColumns(true)

ATK beyond the Pizza Guides
Attributes and relations

     • Use a dialog for adding new records to an
          atkOneToManyRelation
     •    AF_ONETOMANY_ADD_DIALOG or
          AF_ONETOMANY_ADDORCOPY_DIALOG

     • Only useful for simple destination nodes
     • Doesn’t work for destinations containing
          one or more atkFileAttributes!

ATK beyond the Pizza Guides
Attributes and relations

     • Ever wanted to use a normal attribute
          without having it query the database?
     • $attr->setLoadType(NOLOAD)
     • $attr>setStorageType(NOSTORE)
     • Example usage: filtering (using
          dependencies, see next slide)


ATK beyond the Pizza Guides
Attributes and relations

     • Sometimes selections should change based
          on other attribute values
     • $a->addDependee($b)
     • If A changes B is automatically reloaded
     • Common scenario:
       $b = $this->add(new atkManyToOneRelation(‘b’, ...));
          $b->setDestinationFilter(“column = ‘[a]’”);


ATK beyond the Pizza Guides
Attributes and relations

     • Sometimes you only want to show certain
          attributes based on certain conditions
     • $attr->setInitialHidden(...)
     • Adds a special class “atkAttrRowHidden”
          to the attribute’s table row
     • Use JavaScript to show/hide attribute row
          on demand by adding/removing this class

ATK beyond the Pizza Guides
Attributes and relations

     • Next to tabs, attributes can also be placed
          in expandable/collapsable sections
     • Specify a section next to the tab name:
         •    $node->add(..., “tab.section”)

         •    $policy->setSection($attr1, $attr2, “tab.section”)

     • To expand sections by default: ...);
       $node->addDefaultExpandedSections($section,


ATK beyond the Pizza Guides
Attributes and relations

     • Misc. useful methods:
         •    $attr->text(...) - context aware translation

         •    $attr->escapeSQL(...) - database aware escaping
              (knows the database the attribute’s node is using)

         •    $attr->setForceInsert(...) - force insert even though
              the attribute might be read-only

         •    $attr->setForceUpdate(...) - force update even though
              the attribute might be read-only


ATK beyond the Pizza Guides
Partials


ATK beyond the Pizza Guides
Partials

     • Little snippets for (usually) Ajax requests
     • Special request parameter “atkpartial”
          allows specification of partial name.
     • ATK automatically knows not to output a
          full blown page for the registered output
     • URLs should be built using partial_url
ATK beyond the Pizza Guides
Partials

     • Interpretation of partial name depends on
          action handler
     • In your own action handler you are free to
          do whatever you want
     • Best practice: call $handler->partial(...)
     • Searches for “partial_<name>” method
          inside handler

ATK beyond the Pizza Guides
Partials

     • atkAddHandler / atkEditHandler allow
          handling of partials by attributes
     • Partial name: “attribute.<name>.<partial>”
     • Retrieves attribute with specified name and
          calls method “partial_<name>”
     • Method can then return the necessary
          HTML or other output (e.g. JSON)

ATK beyond the Pizza Guides
Partials
     • Used for dependency mechanism between
          attributes (atkAttribute contains special
          “partial_refresh” method)
     • Used for auto-completion mechanism in
          atkManyToOneRelation
     • Used for addition dialog mechanism in
          atkOneToManyRelation
     • Etc.
ATK beyond the Pizza Guides
Partials
     • Always use atkPage to register JavaScript
          code and stylesheets
     • ATK makes sure, even for partials, that the
          JavaScript code gets loaded and executed
          and that stylesheets get registered (when
          needed)
     • Same mechanism is used to append extra
          debug information for partial requests

ATK beyond the Pizza Guides
Data Grid


ATK beyond the Pizza Guides
Data Grid

     • Replaces the record list
     • Uses Ajax to update its contents
     • Easy to use, only a few lines of code
     • Easy to extend using components
     • Can be easily mixed with other instances
          on the same page

ATK beyond the Pizza Guides
Data Grid

     • Usage:atkDataGrid::create($node);
       $grid =
          $result = $grid->render();

     • Calls the current action with “atkpartial”
          set to “datagrid” for updates
     • Updates implemented using:
       $grid = atkDataGrid::resume($node);
          $result = $grid->render();


ATK beyond the Pizza Guides
Data Grid
     • Way too many options to mention here
     • Very flexible; allows you to set almost
          anything from its name to which URL should
          be called for updates to which components
          to use to render the grid etc.
     • Well documented code, so please check the
          generated docs and the code itself
     • Don’t blame me for the atkDGList contents :)
ATK beyond the Pizza Guides
Data Grid
     • Future goals:
      • In-line editing (available as quick hack in
              separate branch, not for production!)
         • Better separation of code and markup
              (especially for list component)
         • Sortable rows?
         • ...?
ATK beyond the Pizza Guides

Contenu connexe

Tendances

Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm OldRoss Tuck
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介Jace Ju
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8PrinceGuru MS
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of LithiumNate Abele
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteLeonardo Proietti
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionNate Abele
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Leonardo Proietti
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingErick Hitter
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APISix Apart KK
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Editionddiers
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Fabien Potencier
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in actionJace Ju
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data ObjectsWez Furlong
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixturesBill Chang
 

Tendances (20)

Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm Old
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment Caching
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Edition
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixtures
 

Similaire à ATK 'Beyond The Pizza Guides'

Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance TriviaNikita Popov
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Designunodelostrece
 
Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Michael Schwern
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngineMichaelRog
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Curscatalyst
CurscatalystCurscatalyst
CurscatalystKar Juan
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail Laurent Dami
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
The Dom Scripting Toolkit J Query
The Dom Scripting Toolkit J QueryThe Dom Scripting Toolkit J Query
The Dom Scripting Toolkit J QueryQConLondon2008
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Michael Wales
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Balázs Tatár
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo van Dam
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netProgrammer Blog
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebookguoqing75
 

Similaire à ATK 'Beyond The Pizza Guides' (20)

Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Hacking Movable Type
Hacking Movable TypeHacking Movable Type
Hacking Movable Type
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance Trivia
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
 
DataMapper
DataMapperDataMapper
DataMapper
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngine
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Slashdot Tags
Slashdot TagsSlashdot Tags
Slashdot Tags
 
The Dom Scripting Toolkit J Query
The Dom Scripting Toolkit J QueryThe Dom Scripting Toolkit J Query
The Dom Scripting Toolkit J Query
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
 
Daily notes
Daily notesDaily notes
Daily notes
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook
 

Dernier

Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docxRodelinaLaud
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdfOrient Homes
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in managementchhavia330
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
 

Dernier (20)

Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.
 
DEPED Work From Home WORKWEEK-PLAN.docx
DEPED Work From Home  WORKWEEK-PLAN.docxDEPED Work From Home  WORKWEEK-PLAN.docx
DEPED Work From Home WORKWEEK-PLAN.docx
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in management
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 

ATK 'Beyond The Pizza Guides'

  • 1. ATK beyond the Pizza Guides Peter C. Verhage - 14th of May 2008 ATK beyond the Pizza Guides
  • 2. Node ATK beyond the Pizza Guides
  • 3. Node • Action triggers: • preAdd(&$record) / postAdd($record) • preUpdate(&$record) / postUpdate($record) • preDelete($record) / postDelete($record) • preCopy(&$record) • Return false to abort action (auto rollback) • Most of the time implemented inside node ATK beyond the Pizza Guides
  • 4. Node • Implement triggers outside a node using a listener (registered using a modifier) • $node->addListener(...) • atkActionListener - deprecated • atkTriggerListener - allows you to implement all previously mentioned triggers inside your own external class with the same behavior ATK beyond the Pizza Guides
  • 5. Node • Less known flags: • NF_TRACK_CHANGES - gives access to the original record for update actions ($record[‘atkorgrec’]) • NF_ADDAFTERADD - allows adding record after record • NF_ADD_DIALOG - add new records inside a dialog • NF_ADDORCOPY_DIALOG - shows a dialog when wanting to add a new record giving the user the choice to copy an existing record or add a new record ATK beyond the Pizza Guides
  • 6. Node • Misc. useful methods: • $node->setDescriptorTemplate($template) - no need to implement descriptor_def anymore • $node->preAddToEditArray(&$record, $mode) - allows you to do last minute modifications to attributes etc. just before a record is edited • $node->text(...) - context aware translations • $node->escapeSQL(...) - database aware escaping (knows the database your node uses) ATK beyond the Pizza Guides
  • 7. Meta Node ATK beyond the Pizza Guides
  • 8. Meta Node • Uses database metadata to detect: • table and sequence name • attributes: • name • type (e.g. date → atkDateAttribute) • flags (AF_OBLIGATORY, AF_PRIMARY...) • order (in regard to other attributes) • default value (limited!) • Only one extends atkMetaNode {} class Person line of code needed: ATK beyond the Pizza Guides
  • 9. Meta Node • Options can be specified using: • protected class variables • array in parent::__construct call (useful for base class!) • Options: name (“people”) • table - table • sequence - sequence name (“seq_person”) • db/database - database name (“default”) • flags - node flags (NF_ADD_LINK etc.) use an array for multiple flags! ATK beyond the Pizza Guides
  • 10. Meta Node • Options (continued): (“[name]”) • descriptor - descriptor template • index - attribute name for index (“name”) • securityAlias - security alias (“module.node”) • securityMap - security map (array(“publish” => “edit”)) • Be careful with inheritance! ATK beyond the Pizza Guides
  • 11. Meta Node • Implement metameta(atkMetaPolicy $policy) public static function method for more control: • Allows full control over attributes and relations • Make sure it’s defined static to let the caching mechanism kick in! • Make full use of inheritance by calling parent::meta($policy) ATK beyond the Pizza Guides
  • 12. Meta Node • Control which columns to expose: • $policy->setExcludes($attr1, $attr2, ...) - exclude certain attributes • $policy->setIncludes($attr1, $attr2, ...) - only include the given attributes, implicitly sets the attribute order! • $policy->remove($attr) - removes a single attribute ATK beyond the Pizza Guides
  • 13. Meta Node • Control attribute flags: • $policy->addFlags($attr1, $attr2, ..., $flags) - add the given flag(s) for the given attributes • $policy->removeFlags($attr1, $attr2, ..., $flags) - remove the given flags(s) for the given attributes • $policy->setFlags($attr1, $attr2, ..., $flags) - explicitly set the flags for the given attributes (dangerous!) • Alternatives: $policy->addFlag, $policy->removeFlag ATK beyond the Pizza Guides
  • 14. Meta Node • Control attribute tabs/sections: • $policy->setSections($attr1, $attr2, ..., $sections) - sets the tabs/sections for the given attributes • $sections can be either a single tab/section name or an array of tab/section names • Format: <tab> or <tab>.<section> • Previously set tabs/sections will be ignored! • Alternatives: $policy->setSection, $policy->setTabs, $policy->setTab ATK beyond the Pizza Guides
  • 15. Meta Node • Forcing insertion/updates: • $policy->addForceInsert($attr1, $attr2, ...) - set force insert to true for the given attributes • $policy->removeForceInsert($attr1, $attr2, ...) - don’t force insertion of the given attributes • $policy->addForceUpdate($attr1, $attr2, ...) - set force update to true for the given attributes • $policy->removeForceUpdate($attr1, $attr2, ...) - don’t force update of the given attributes ATK beyond the Pizza Guides
  • 16. Meta Node • Changing attribute types and parameters: • $policy->setType($attr, $type, $param1, ...) - sets the attribute type for the given attribute(s) and uses the given parameters when constructing the attribute • $attr can be a single attribute name or an array • $type can be anything that is valid for useattrib, userelation or atkimport (and knows about the node’s module) • Parameters (optional) are passed as extra arguments ATK beyond the Pizza Guides
  • 17. Meta Node • Changing attribute types and parameters (alternative): • $policy->setTypeAndParams($attr, $type, $params) - sets the attribute type for the given attribute(s) and uses the given parameters when constructing the attribute • Same as $policy->setType, but parameters are passed as a single array and not as separate arguments ATK beyond the Pizza Guides
  • 18. Meta Node • Adding / overwriting attributes: • $policy->add($name, $type [, $params [, $flags]]) • $type can be anything that is valid for useattrib, userelation or atkimport (and knows about the node’s module) • $params should contain an array of attribute parameters (at least all mandatory parameters!) • $flags should contain the attribute flags (int) • Overwrite the current attribute entry (if applicable)! ATK beyond the Pizza Guides
  • 19. Meta Node • Many-to-one relation: • $policy->hasOne($accessor) • $accessor is the destination node • Format: <module>.<node> • If part of the same module, module can be ommitted • Automatic translation from singular accessor names to plural node names (e.g. person → people) ATK beyond the Pizza Guides
  • 20. Meta Node • Many-to-one relation (continued...): • Local attribute name is automatically detected (tries mutiple variants based on the destination node name and module name e.g. people_id, person_id, people, person etc.) • $policy->hasOne($accessor, $descriptor) • Descriptor can be specified as second parameter (overrides default descriptor in destination node) • Format: “[name] ([city])” ATK beyond the Pizza Guides
  • 21. Meta Node • Many-to-one relation (continued...): • $policy->hasOne($accessor, [$descriptor,] $options) • Options can be specified as 2nd or 3rd argument (depending on whatever a descriptor is specified) • Array containing the following options (all optional): • source - local attribute name • filter - destination where clause • large - true/false, sets the AF_LARGE flag ATK beyond the Pizza Guides
  • 22. Meta Node • One-to-one relation • $policy->hasOne($accessor [, $options]) • Uses same method as many-to-one relation • Difference detected based on availability of local attribute (if not available → 1:1) • Options: • filter - destination where clause • dest(-ination) - destination node attribute (forces 1:1) ATK beyond the Pizza Guides
  • 23. Meta Node • One-to-many relation: • $policy->hasMany($accessor [, $options]) • $accessor is the destination node • Format: <module>.<node> • If part of the same module, module can be ommitted • Automatic translation from plural accessor names to singular node names (e.g. people → person) ATK beyond the Pizza Guides
  • 24. Meta Node • One-to-many relation (continued...): • Destination attribute name is automatically detected (tries mutiple variants based on the local node name and module name e.g. departments_id, department_id, departments, department etc.) • Possible options ($options array): • dest(-ination) - name of the attribute in the destination node for this relation • filter - destination node where clause • name - local attribute name for relation ATK beyond the Pizza Guides
  • 25. Meta Node • Many-to-many relation: • $policy->hasMany($accessor [, $descriptor], $options) • Uses same method as one-to-many relation • Descriptor is optional (if ommitted options need to be specified as second argument) • Mandatory option “through” is used to detect that this is a many-to-many relation and should contain an accessor name for the link node ATK beyond the Pizza Guides
  • 26. Meta Node • Many-to-many relation (continued...): • Example: $policy->hasMany(“people”, array(“through” => “department_person”)) • Other options: • type - display type: shuttle (default), bool(-ean), list, select, eshuttle (extended shuttle) • local / remote - link node local / remote key • filter - destination node where clause • type specific options (cols/columns, rows) ATK beyond the Pizza Guides
  • 27. Meta Node • Misc. methods: • $policy->setOrder($attr1, $attr2, ...) - sets the order of the attributes, all attributes not mentioned will keep their current order but are placed after the explicitly mentioned attributes • $policy->setDefaultValue($attr1, $attr2, ..., $value) - sets the initial value for the given attributes • $policy->text($string) - same as atktext but keeps module and node type into account ATK beyond the Pizza Guides
  • 28. Meta Node • More control needed? • public function postMeta() • Called after node has been configured and attributes/relations have been added • Early enough to do some more customizations ATK beyond the Pizza Guides
  • 29. Meta Node • Configuration options: • $config_meta_caching - controls whatever generated code for meta nodes should be cached or not, turn of during development! • $config_meta_policy - can be used to set an application wide alternative for the default policy class • $config_meta_compiler - allows customization of the meta policy compiler (only useful in rare cases) • $config_meta_grammar - allows customization of the singular / plural grammar rules (person → people) ATK beyond the Pizza Guides
  • 30. Meta Policy ATK beyond the Pizza Guides
  • 31. Meta Policy • Responsible for detecting the defaults for a meta node (table, attributes etc.) • Can be subclassed for supporting your own set of rules • Use $config_meta_policy to set an application wide policy • Can be specified per node using the $metaPolicy option (or in base class!) ATK beyond the Pizza Guides
  • 32. Meta Policy • Customizable methods: • _getTypeAndParams($name, $meta) - should return an array with key “type” and “params” containing the attribute type and array of parameters • _getFlags($name, $meta) - should return the attribute flags (int) • _getOrder($name, $meta) - should return the order (index) for the attribute • _getDefaultValue($name, $meta) - should return the default value for the attribute ATK beyond the Pizza Guides
  • 33. Meta Policy • Customizable methods (continued...): • $name contains the column name • $meta contains the column metadata and consists of: • gentype - generic data type • num - column index • flags - flags; MF_PRIMARY, MF_NOT_NULL etc. • default - detected default value ATK beyond the Pizza Guides
  • 34. Attributes and relations ATK beyond the Pizza Guides
  • 35. Attributes and relations • ATK contains: • More than 50 attributes • More than 10 relations • Still growing each day • Luckily they are pretty well named :) • Some highlights of less known attributes, relations and features you probably don’t know about ATK beyond the Pizza Guides
  • 36. Attributes and relations • Tracking of modifications; who / when • Attributes: • atkCreatedByAttribute - added by user ... • atkCreateStampAttribute - created at • atkUpdatedByAttribute - last updated by user ... • atkUpdateStampAttribute - last updated at • Automatically used by meta node for fields with correct type and name: created_by, created_at, updated_by, updated_at ATK beyond the Pizza Guides
  • 37. Attributes and relations • atkExpressionAttribute • Custom expressions in select statement • Anything that is allowed by the database (subqueries, function calls etc.) • Even supports sorting and limited searching ATK beyond the Pizza Guides
  • 38. Attributes and relations • atkTabbedPane • Allows you to created nested tabs • Simply name the attributes you want to show on each tab • Attributes are automatically “removed” from their normal position • Use carefully (keep interface simple!) ATK beyond the Pizza Guides
  • 39. Attributes and relations • atkRadioDetailsAttribute • Allows you to show detail selections based on radio button selections • Works similar to atkTabbedPane • Still has some rough edges but will be improved in the near future ATK beyond the Pizza Guides
  • 40. Attributes and relations • Many many-to-many relations: • atkManyBoolRelation - checkboxes • atkShuttleRelation - move items between two lists • atkExtendableShuttleRelation - allows filtering of shuttle lists (will eventually supersede atkShuttleRelation) • atkManyToManySelectRelation - multi select list • atkManyToManyListRelation - add items one by one using auto-completion or drop-down ATK beyond the Pizza Guides
  • 41. Attributes and relations • atkManyToOneRelation auto-completion • AF_MANYTOONE_AUTOCOMPLETE • Many options: • $rel->setAutoCompleteMinRecords($recs) • $rel->setAutoCompleteCaseSensitive($value) • $rel->setAutoCompleteSearchFields($fields) • $rel->setAutoCompleteSearchMode($mode) (exact, startswith, contains) • By default searches descriptor fields ATK beyond the Pizza Guides
  • 42. Attributes and relations • Showing more than one column for an atkManyToOneRelation in list view • $rel->addListColumn($col) or $rel->addListColumns($col1, $col2, ...) • Allows full sorting and searching • Only want to show extra columns? • AF_HIDE_LIST • $rel->setAlwaysShowListColumns(true) ATK beyond the Pizza Guides
  • 43. Attributes and relations • Use a dialog for adding new records to an atkOneToManyRelation • AF_ONETOMANY_ADD_DIALOG or AF_ONETOMANY_ADDORCOPY_DIALOG • Only useful for simple destination nodes • Doesn’t work for destinations containing one or more atkFileAttributes! ATK beyond the Pizza Guides
  • 44. Attributes and relations • Ever wanted to use a normal attribute without having it query the database? • $attr->setLoadType(NOLOAD) • $attr>setStorageType(NOSTORE) • Example usage: filtering (using dependencies, see next slide) ATK beyond the Pizza Guides
  • 45. Attributes and relations • Sometimes selections should change based on other attribute values • $a->addDependee($b) • If A changes B is automatically reloaded • Common scenario: $b = $this->add(new atkManyToOneRelation(‘b’, ...)); $b->setDestinationFilter(“column = ‘[a]’”); ATK beyond the Pizza Guides
  • 46. Attributes and relations • Sometimes you only want to show certain attributes based on certain conditions • $attr->setInitialHidden(...) • Adds a special class “atkAttrRowHidden” to the attribute’s table row • Use JavaScript to show/hide attribute row on demand by adding/removing this class ATK beyond the Pizza Guides
  • 47. Attributes and relations • Next to tabs, attributes can also be placed in expandable/collapsable sections • Specify a section next to the tab name: • $node->add(..., “tab.section”) • $policy->setSection($attr1, $attr2, “tab.section”) • To expand sections by default: ...); $node->addDefaultExpandedSections($section, ATK beyond the Pizza Guides
  • 48. Attributes and relations • Misc. useful methods: • $attr->text(...) - context aware translation • $attr->escapeSQL(...) - database aware escaping (knows the database the attribute’s node is using) • $attr->setForceInsert(...) - force insert even though the attribute might be read-only • $attr->setForceUpdate(...) - force update even though the attribute might be read-only ATK beyond the Pizza Guides
  • 49. Partials ATK beyond the Pizza Guides
  • 50. Partials • Little snippets for (usually) Ajax requests • Special request parameter “atkpartial” allows specification of partial name. • ATK automatically knows not to output a full blown page for the registered output • URLs should be built using partial_url ATK beyond the Pizza Guides
  • 51. Partials • Interpretation of partial name depends on action handler • In your own action handler you are free to do whatever you want • Best practice: call $handler->partial(...) • Searches for “partial_<name>” method inside handler ATK beyond the Pizza Guides
  • 52. Partials • atkAddHandler / atkEditHandler allow handling of partials by attributes • Partial name: “attribute.<name>.<partial>” • Retrieves attribute with specified name and calls method “partial_<name>” • Method can then return the necessary HTML or other output (e.g. JSON) ATK beyond the Pizza Guides
  • 53. Partials • Used for dependency mechanism between attributes (atkAttribute contains special “partial_refresh” method) • Used for auto-completion mechanism in atkManyToOneRelation • Used for addition dialog mechanism in atkOneToManyRelation • Etc. ATK beyond the Pizza Guides
  • 54. Partials • Always use atkPage to register JavaScript code and stylesheets • ATK makes sure, even for partials, that the JavaScript code gets loaded and executed and that stylesheets get registered (when needed) • Same mechanism is used to append extra debug information for partial requests ATK beyond the Pizza Guides
  • 55. Data Grid ATK beyond the Pizza Guides
  • 56. Data Grid • Replaces the record list • Uses Ajax to update its contents • Easy to use, only a few lines of code • Easy to extend using components • Can be easily mixed with other instances on the same page ATK beyond the Pizza Guides
  • 57. Data Grid • Usage:atkDataGrid::create($node); $grid = $result = $grid->render(); • Calls the current action with “atkpartial” set to “datagrid” for updates • Updates implemented using: $grid = atkDataGrid::resume($node); $result = $grid->render(); ATK beyond the Pizza Guides
  • 58. Data Grid • Way too many options to mention here • Very flexible; allows you to set almost anything from its name to which URL should be called for updates to which components to use to render the grid etc. • Well documented code, so please check the generated docs and the code itself • Don’t blame me for the atkDGList contents :) ATK beyond the Pizza Guides
  • 59. Data Grid • Future goals: • In-line editing (available as quick hack in separate branch, not for production!) • Better separation of code and markup (especially for list component) • Sortable rows? • ...? ATK beyond the Pizza Guides