Your SlideShare is downloading. ×
Pecha Kucha
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Pecha Kucha

554
views

Published on

Awesome-sauce CakePHP Pecha Kucha Talk by yours truly

Awesome-sauce CakePHP Pecha Kucha Talk by yours truly


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
554
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. AUTHSOME PLUGINS FOR CAKEPHP
    • 2. ~WHOAMI• Jose Diaz-Gonzalez• Resident IRC Troll (savant)• Rants at http://josediazgonzalez.com ➘• Harasses as @savant me• Codes as josegonzalez on github• EMPLOYED at @seatgeek not me ➘ I’m also hot like sriracha sauce
    • 3. AUTHSOMEhttps://github.com/felixge/cakephp-authsome/**
*
Finds
the
current
user
for
the
dashboard
*
*
@param
string
$state
Either
"before"
or
"after"
*
@param
array
$query
*
@return
mixed
array
of
results
or
false
if
none
found
*
@return
array
*/



function
_findUser($state,
$query,
$results
=
array())
{







if
($state
==
before)
{











$user_id
=
false;











if
(!empty($query[0]))
{















$user_id
=
$query[0];











}
elseif
(!empty($query[id])){















$user_id
=
$query[id];











}
else
{















$user_id
=
Authsome::get($this‐>primaryKey);











}











if
(empty($user_id))
{















throw
new
OutOfBoundsException(__(Invalid
maintainer,
true));











}











$query[contain]
=
false;











$query[conditions]
=
array("{$this‐>alias}.{$this‐>primaryKey}"
=>
$user_id);











$query[limit]
=
1;











return
$query;







}
elseif
($state
==
after)
{











if
(empty($results[0]))
{















throw
new
OutOfBoundsException(__(Invalid
user,
true));











}











return
$results[0];







}



}
    • 4. SEARCH<?php https://github.com/CakeDC/Searchclass
Article
extends
AppModel
{



public
$actsAs
=
array(Search.Searchable);



public
$belongsTo
=
array(User);



public
$hasAndBelongsToMany
=
array(Tag
=>
array(with
=>
Tagged));



public
$filterArgs
=
array(







array(name
=>
title,
type
=>
like),







array(name
=>
status,
type
=>
value),







array(name
=>
blog_id,
type
=>
value),







array(name
=>
search,
type
=>
like,
field
=>
Article.description),







array(name
=>
username,
type
=>
like,
field
=>
User.username),







array(name
=>
tags,
type
=>
subquery,
method
=>
findByTags,
field
=>
Article.id),







array(name
=>
filter,
type
=>
query,
method
=>
orConditions),



);



public
function
findByTags($data
=
array())
{







$this‐>Tagged‐>Behaviors‐>attach(Containable,
array(autoFields
=>
false));







$this‐>Tagged‐>Behaviors‐>attach(Search.Searchable);







$query
=
$this‐>Tagged‐>getQuery(all,
array(











conditions
=>
array(Tag.name

=>
$data[tags]),











fields
=>
array(foreign_key),











contain
=>
array(Tag)







));







return
$query;



}



public
function
orConditions($data
=
array())
{







$filter
=
$data[filter];







$cond
=
array(











OR
=>
array(















$this‐>alias
.
.title
LIKE
=>
%
.
$filter
.
%,















$this‐>alias
.
.body
LIKE
=>
%
.
$filter
.
%,











));







return
$cond;



}}
    • 5. LAZY MODELhttps://github.com/Phally/lazy_model
    • 6. ASSET COMPRESShttps://github.com/markstory/asset_compress
    • 7. DEBUG KIThttps://github.com/cakephp/debug_kit
    • 8. CODE CHECKhttps://github.com/petteyg/code_check
    • 9. RESQUE PLUGINhttps://github.com/mikesmullin/CakePHP-PHP-Resque-Plugin