Zend Framework 1.5 Certification Flashcards

Terms Definitions
What is Zend_Auth?
Authentication API for verifying a user's identity against some predetermined criteria
How is Zend_Auth used?
Call static getInstance() and use an authentication service adapter such as LDAP, RDBMS, etc. Then, call functions such as isValid() and getIdentity().
What is Zend_Auth Identity Persistence?
Use of a storage class (Zend_Session by default) that retains the identity across requests in accordance with PHP session configuration. Custom classes implement Zend_Auth_Storage_Interface and pass it to Zend_Auth::setStorage().
What does the Zend_Auth adapter authenticate() method return?
Instance of Zend_Auth_Result with functions such as isValid(), getCode(), getIdentity(), getMessages().
What are some Zend_Auth adapters?
What does Zend_Auth adapter's isValid() return?
TRUE if and only if the result represents a successful authentication attempt.
What does Zend_Auth adapter's getCode() return?
A constant identifier for confirming success or determining the type of authentication failure.
What does Zend_Auth adapter's getIdentity() return?
The identity of the authentication attempt, such as the username.
What does Zend_Auth adapter's getMessages() return?
An array of messages regarding a failed authentication attempt.
What is Zend_Acl?
Access control list component to handle authorizing access; privileges management.
What are a couple ways to integrate Zend_Acl into your MVC application?
Action Helper or Front Controller Plugin
What do you call combining the process of authentication and authorization?
"Access Control"
What is a Zend_Acl "Resource"?
An object with controlled access.
What is a Zend_Acl "Role"?
An object that requests access to a resource.
What two functions are used to specify Zend_Acl access control rules?
Zend_Acl::allow() and Zend_Acl::deny()
When will Zend_Acl::isAllowed() throw an exception?
When it is called against a Role or Resource that was not previously added to the ACL results.
How is a Zend_Acl created?
require_once 'Zend/Acl.php'$acl = new Zend_Acl();
How is a Zend_Acl resource created?
Implement the Zend_Acl_Resource_Interface or extend Zend_Acl_Resource. Should have the single method getResourceId().
How is a Zend_Acl role created?
Implement the Zend_Acl_Role_Interface or extend Zend_Acl_Role. Should have the single method getRoleId().
How does Zend_Acl resource inheritance work?
Queries on a specific resource with automatically search the hierarchy for rules assigned to its parent resources. Can inherit from only one parent resource.
How does Zend_Acl role inheritance work?
Multiple inheritance is possible. For rule conflicts the first rule found via query wins.
What interface and method provides support for implementing role or resource access rules based on conditions to be met?
Use the Zend_Acl_Assert_Interface and the assert() method.
Zend_Acl supports ______ inheritance among Resource objects.
True or False: Zend_Auth throws an exception upon an unsuccessful authentication attempt due to invalid credentials (e.g., the username does not exist).
In the Zend coding standard, should you use the closing tag "?>" for files that contain only PHP code?
In the Zend coding standard, how should code be indented?
4 spaces, not tabs
In the Zend coding standard, should all PHP files have the extension .php?
Yes, except view files.
In the Zend coding standard, what should accessors for objects be prefixed with?
Either "get" or "set"
In the Zend coding standard, when is the only time a variable must begin with an underscore?
Private or protected class member variables
In the Zend coding standard, where should the concatenation operator be placed when breaking long lines?
Directly under the "=" operator.
In the Zend coding standard, which is valid: "elseif" or "else if"?
else if
True or false: In the Zend coding standard, all switch statements must have a default case.
In Zend coding standard, what documentation format should doc blocks be compatible with?
In Zend coding standard, what tags should exist in the top of the PHP files?
@copyright, @license, @version, @link, and @since
In Zend coding standard, what tags must every class-level docblock contain?
@copyright, @license, @version, @link, @since, and @deprecated
Is the following class name valid?: My_Foo_123
The filename "Zend/Db/Table.php" must map to the class name ______.
What is the base class used for connecting PHP applications to a RDBMS?
How can you dynamically load the Adapter class on demand?
Use the static method Zend_Db::factory() which utilizes Zend_Loader::loadClass()
What parameters can be passed to the Zend_Db::factory() method?
Either a Zend_Config object or an associative array.
With Zend_Db, when is a connection to the database first created?
Triggered the first time a query is executed, or when the getConnection() method is called.
Suppose you have: $db = Zend_Db::factory('Pdo_Mysql', $params)$sql = 'SELECT * FROM bugs WHERE bug_id = ?';How would you execute this query using the bug_id = 2?
$result = $db->fetchAll($sql, 2)
What method should be used to change the result structure of Zend_Db's fetchAll()? What are the valid mode constants?
Use the setFetchMode() method. Constants are Zend_Db::FETCH_ASSOC, Zend_Db::FETCH_BOTH, Zend_Db::FETCH_COLUMN, Zend_Db::FETCH_NUM, Zend_Db::FETCH_OBJ
What are the parameters to Zend_Db insert()?
First parameter is a string naming the table, and second is an associative array mapping column names to data values.
What is the difference between Zend_Db quote() and quoteInto()?
The quote() method escapes a given string. The quoteInto() method interpolates using the placeholder symbol (?) and a value.
What method is used to quote RDBMS identifiers?
Use the quoteIdentifier() method.
What is returned by the Zend_Db query() method?
A statement object Zend_Db_Statement
How are named parameters used with the Zend_Db_Statement?
In the query string, use the string identifier preceded by a colon character (:) and pass the bind values in an associative array.
How do you execute a statement object with two placeholders, say, "A" and 123?
$stmt->execute("A", 123);
Name 4 different SQL statement types that can be used with fetch() in a loop.
What are some fluent methods of the Zend_Db_Select object?
where(), order(), from()
Using the Zend_Db_Select fluent interface, how would you build the following query:SELECT b."book_id" AS TheBookID, b."book_name" FROM "books" as b
$select = $db->select()->from(array('b' => 'books'), array('TheBookID' => 'book_id', 'book_name'));
Using the Zend_Db_Select fluent interface, how would you build the following query:SELECT b."book_id", b."book_name", a.* FROM "books" AS b JOIN "authors" AS a ON b.author_id = a.id
$select = $db->select()->from(array('b' => 'books'), array('book_id', 'book_name'))->join(array('a' => 'authors'), 'b.author_id = a.id');
What class/interface should you extend or implement to build your own Zend_Db table class?
extend Zend_Db_Table_Abstract
True or false: Zend_Db automatically uses the class name as the table name if $this->_name is not provided.
What are the four setup methods that can be overridden in your Zend_Db table class?
_setupDatabaseAdapter(), _setupTableName(), _setupMetadata(), and _setupPrimaryKey()
True or false: Zend_Db contains a factory() method by which you may instantiate a database adapter object.
True or false: Zend_Db_Select supports querying columns containing expressions (e.g., LOWER(someColumn)).
How could you add additional writers to a Zend_Log?
Use the addWriter() method.
What is the second parameter to the Zend_Log log() method?
The integer priority level, such as Zend_Log::INFO.
How would you write log data using Zend_Log to the PHP output buffer?
$writer = new Zend_Log_Writer_Stream('php://output');$logger = new Zend_Log($writer);
Name two Zend_Log formatter classes.
Zend_Log_Formatter_Simple and Zend_Log_Formatter_Xml
How would you add a filter to a log such that only warnings and higher are logged?
$filter = new Zend_Log_Filter_Priority(Zend_Log::WARN);$writer->addFilter($filter);
What are the parameters to Zend_Debug::dump()?
First is the variable, second is the label, and third is whether or not to output.
Which one of the following will not display the value of $var?a. echo Zend_Debug::dump($var, 'far', false);b. ob_start(); Zend_Debug::dump($var, 'var', false); ob_end_flush();c. Zend_Debug::dump($var, 'var', true)d. Zend_Debug::dump($var, 'var')
Which formatters are provided with Zend_Log? (choose two)a. Zend_Log_Formatter_Dbb. Zend_Log_Formatter_Simplec. Zend_Log_Formatter_Textd. Zend_Log_Formatter_Xml
b and d
How would you chain a alphabetic filter and lowercase filter?
$filterChain = new Zend_Filter();$filterChain->addFilter(new Zend_Filter_Alpha())->addFilter(new Zend_Filter_StringToLower());
How would you create your own custom filter?
Create a class that implements Zend_Filter_Interfaces and has a filter() method.
What does Zend_Validate getMessages() return?
An array of messages explaining the reason(s) for validation failure. The array keys identify string codes and array values are readable messages.
What is the second parameter to the Zend_Validate::is() function?
The basename of the validation class relative to the Zend_Validate namespace.
What are the 19 standard validation classes?
Alnum, Alpha, Barcode, Between, Ccnum, Date, Digits, EmailAddress, Float, GreaterThan, Hex, Hostname, InArray, Int, Ip, LessThan, NotEmpty, Regex, StringLength
Which of the following could be used to validate an email address (choose 2):a. Zend_Validate::is($email, 'EmailAddress');b. Zend_Validate::isValid($email, 'EmailAddress');c. $validator = new Zend_Validate_EmailAddress();if ($validator->isValid($email)) {
a and c
Which of the following can be used to produce:
from the following input:
a. Zend_Filter_StripTags
b. Zend_Text
c. Zend_Uri
d. Zend_View
How do you set the form action and method using Zend_Form?
Use the setAction() and setMethod() methods.
What are the 13 built-in Zend_Form elements?
button, hidden, image, radio, reset, submit, password, text, textarea, checkbox, multiCheckbox, select, multiselect
What are the 4 ways to add elements to a form?
1. instantiate concrete elements and pass in these objects2. pass in the element type3. use createElement() and addElement()4. use a configuration
When using addValidator() by string type, how can you specify the validation class constructor arguments?
Passed in as an array as the third parameter.
What are two ways to add validators to the chain?
Passing in a concrete validator instance or providing a validator name (short or fully qualified)
What does the second parameter to addValidator() do?
If set to true, the particular validation failure will prevent later validators from firing.
What does setAutoInsertNotEmptyValidator(false) do?
A 'NotEmpty' validator will not be prepended to the validator chain when the element is required.
How would you add a prefix/path association loader where the class names begin with "My_" and the files are located in /usr/lib/php/My such as /usr/lib/php/My/Validate/Example.php with class My_Validate_Example and /usr/lib/php/My/Filter/Example.php with
addPrefixPath('My', '/usr/lib/php/My')
What four decorators does Zend_Form_Element use to achieve output?
ViewHelper, Errors, HtmlTag, and Label
How can you disable default decorators from loading during object initialization?
$element = new Zend_Form_Element('foo', array('disableLoadDefaultDecorators' => true));
What are the 6 setters that cannot be set using the Zend_Config key method for Zend_Form_Element constructors?
setAttrib, setConfig, setOptions, setPluginLoader, setTranslator, setView
How could you group together the elements 'firstName' and 'lastName' as the 'userInfo' group with Zend_Form?
$form->addDisplayGroup(array('firstName', 'lastName'), 'userInfo');
True or false: The master form object will have awareness of the elements in sub forms.
What are two ways of retrieving a sub form?
$subForm = $form->getSubForm('subform')or$subForm = $form->subform;
True or false: By default, Zend_Forms will perform internationalization.
How do you turn on i18n features in Zend_Form?
Validators used with Zend_Form should implement which component?a. Zend_Form_Validator_Abstractb. Zend_Validate_Abstractc. Zend_Validate_Interfaced. Zend_Form_Validate_Interface
Which of the following is NOT a valid mechanism for adding a decorator to an element?a. $element->addDecorator(new Zend_Form_Decorator_ViewHelper());b. $element->attachDecorator('ViewHelper');c. $element->addDecorator('ViewHelper');d. $element->addDecorat
What are two commonly used Zend_Config adapters?
Zend_Config_Ini and Zend_Config_Xml
What does the second parameter to Zend_Config_Ini's constructor do?
It specifies the specific ini section to be used.
What do the return values of Zend_Version::compareVersion() mean?
0 means the version is the same, -1 if the specified version is older than the Zend Framework version, and +1 if the specified version is newer than the Zend Framework version.
How can you use a new instance of Zend_Registry as the static instance?
Call Zend_Registry::setInstance($registry)
What are the restrictions to the filename aregument to Zend_Loader::loadFile()?
The filename can only contain alphanumeric characters, hypens, underscores, or periods, and must not contain any path information.
What is the second argument to Zend_Loader::loadClass()?
An array of the directories to search.
In what order are plugin class paths searched for Zend_Loader_PluginLoader?
Searched in LIFO (Last In, First Out) order.
True or false: Zend_Auth uses Zend_Session_Namespace to store some information associated with authenticated users.
When does Zend_Session start the PHP session?
It will be started when the first session namespace is requested or when Zend_Session::start() is called.
How do you reset the expiration time of data in Zend_Session?
Fetch the data into temporary variables, use the namespace to unset then, and then set the appropriate keys again.
True or false: Zend_Config allows hierarchical and sectioned key-value pairs to exist in a single file.
Given $tree = new Tree(array('type' => 'cedar')); and you wish to persist this object via Zend_Session, which call will put this object in the default namespace?a. Zend_Session_Namespace::set('tree', $tree);b. $sess = new Zend_Session_Namespace();$sess->t
What is the first parameter to the Zend_Locale constructor?
The method used to determine the correct locale, such as:$locale = new Zend_Locale(Zend_Locale::BROWSER)
What are the three automatic locales provided by Zend_Locale that do not belong to any language or region?
browser, environment, and auto
How can Zend_Locale and Zend_Locale_Format performance be improved with caching?
Zend_Locale::setCache($cache) and Zend_Locale_Format::setOptions(array('cache' => $adapter))
What does Zend_Locale's getDefault() method return?
Returns all default locales.
What does the Zend_Locale getTranslationList() do?
Provides access to localized information of various types, without the need for translation.
Name 8 built-in adapters for Zend_Translate.
Array, Tbx, Xliff, Csv, Tmx, XmlTm, Gettext, Qt
What option is available to all Zend_Translate adapters and what does it do?
The 'clear' option; it decides if translation data should be added to existing content or not.
What are three ways Zend_Translate finds translation sources?
1. When addTranslation() is used2. When the 'scan' option is used with Zend_Translate and naming the language source directories3. When the 'scan' option is used with Zend_Translate and use special filenames with the entire language file or parts of it.
What five methods operate generically on Zend_Date?
add(), sub(), compare(), get(), and set()
What does the Zend_Date method's $parts parameter do?
A constant can be used in order to select a specific part of a date or to indicate the date format used or desired.
What method is used to check if a date string is a real date?
How is the Zend_Currency locale set?
If no parameters are used, it will use the actual locale and it's related currency. If it can't be detected, it throws an exception.
What method is used to convert an existing value to a currency formatted output?
What method is used to convert localized numbers to normalized numbers?
What is the first parameter to Zend_Currency::toCurrency()?
An array with options that can set another format or currency representation.
What are three ways of initiating the Translate View Helper?
1. Registered through a previously registered instance in Zend_Registry2. Afterwards through the fluent interface3. Directly, through initiating the class.
What method of Zend_Locale will check if a given string is a locale?
Which Zend_Date constant should you use when you want to have the date formatted for an RSS feed?a. Zend_Date::RSS_FEEDb. Zend_Date::RSS2c. Zend_Date::RSSd. Zend_Date::RSSFEED
What Zend_Mail method returns an array with all recipient email addresses that were added prior to the method call?
How do you set the MIME content type to text/html when using Zend_Mail?
Set the body using the method setBodyHtml() instead of setBodyText()
What Zend_Mail method is used to attach files to e-mails?
What is the return value of Zend_Mail::createAttachment()?
a Zend_Mime_Part object that can be used to modify it's MIME attributes before sending the mail
What is the first parameter to Zend_Mail::send()?
You can pass a different transport.
What are the three ways recipients can be added to Zend_Mail?
addTo(), addCc(), and addBcc()
What default encoding mechanism is used for Text/HTML bodies and for attachments?
The 'quotedprintable' mechanism and base64 for attachments.
What are four mail storage systems that Zend_Mail can read from?
Mbox, Maildir, Pop3, and IMAP
How would you read message #123 from a Mbox file located at /var/mail/inbox?
$mail = new Zend_Mail_Storage_Mbox(array('filename' => '/home/test/mail/inbox'));$message = $mail->getMessage(123);
How would you read the 'received' message header as an array from a Zend_Mail_Storage_Mbox?
$received = $message->getHeader('received', 'array');
True or false: Zend_Mail content can be fetched using getContent(), even if the mail has a multi-part message.
What two methods are useful for multi-part Zend_Mail messages?
isMultipart() and getPart()
What Maildor and IMAP flags can be used for checking if a message is seen or is recent?
Zend_Mail_Storage::FLAG_SEEN andZend_Mail_Storage::FLAG_RECENT
What two classes handle local storage Zend_Mail folders?
Zend_Mail_Storage_Folder_Mbox and Zend_Mail_Storage_Folder_Maildir
What interface does Zend_Mail_Storage_Folder implement?
the RecursiveIterator interface
What three methods are useful for dealing with changing Zend_Mail folders?
isSelectable(), getSelectedFolder(), and selectFolder()
What magic methods do Zend_Mail_Storage_Folder_Maildir implement?
__sleep() and __wakeup()
What two classes should you extend to add features to the Pop3 protocol?
Zend_Mail_Protocol_Pop3 and Zend_Mail_Storage_Pop3
With quotas enabled which methods might fail because you're over quota? (choose TWO)a. appendMessage()b. removeMessage()c. createFolder()d. getMessage()
a and b
How would you connect to a Pop3 server using TLS?a. $mail = new Zend_Mail_Storage_Pop3_Tls(array('host' => 'example.com', 'user' => 'test'));b. $mail = new Zend_Mail_Storage_Pop3(array('host' => 'example.com', 'user' => 'test', 'ssl' => true));c. $mail =
/ 141

Leave a Comment ({[ getComments().length ]})

Comments ({[ getComments().length ]})


{[ comment.comment ]}

View All {[ getComments().length ]} Comments
Ask a homework question - tutors are online