You are here

static function flag_flag::factory_by_array in Flag 7.3

Same name and namespace in other branches
  1. 5 flag.inc \flag_flag::factory_by_array()
  2. 6.2 flag.inc \flag_flag::factory_by_array()
  3. 6 flag.inc \flag_flag::factory_by_array()
  4. 7.2 flag.inc \flag_flag::factory_by_array()

Create a complete flag (except an FID) from an array definition.

4 calls to flag_flag::factory_by_array()
FlagLinkTypeConfirmTestCase::setUp in tests/flag.test
Implements setUp().
FlagTestCaseBase::createFlag in tests/flag.test
Helper to create a flag from an array of data and clear caches etc.
flag_get_default_flags in ./flag.module
Retrieve a list of flags defined by modules.
flag_import_form_validate in includes/flag.export.inc
Validate handler; Import a flag.

File

includes/flag/flag_flag.inc, line 151
Contains the flag_flag class. Flag type classes use an object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

static function factory_by_array($config) {

  // Allow for flags with a missing entity type.
  $config += array(
    'entity_type' => FALSE,
  );
  $flag = flag_create_handler($config['entity_type']);
  foreach ($config as $option => $value) {
    $flag->{$option} = $value;
  }
  if (isset($config['locked']) && is_array($config['locked'])) {
    $flag->locked = drupal_map_assoc($config['locked']);
  }
  return $flag;
}