You are here

class DemoContentParser in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  2. 8.2 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  3. 8.3 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  4. 8.4 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  5. 8.5 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  6. 8.6 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  7. 8.7 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  8. 8.8 modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  9. 10.3.x modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  10. 10.0.x modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  11. 10.1.x modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser
  12. 10.2.x modules/custom/social_demo/src/DemoContentParser.php \Drupal\social_demo\DemoContentParser

Class DemoContentParser.

@package Drupal\social_demo

Hierarchy

Expanded class hierarchy of DemoContentParser

1 string reference to 'DemoContentParser'
social_demo.services.yml in modules/custom/social_demo/social_demo.services.yml
modules/custom/social_demo/social_demo.services.yml
1 service uses DemoContentParser
social_demo.yaml_parser in modules/custom/social_demo/social_demo.services.yml
\Drupal\social_demo\DemoContentParser

File

modules/custom/social_demo/src/DemoContentParser.php, line 12

Namespace

Drupal\social_demo
View source
class DemoContentParser extends Yaml implements DemoContentParserInterface {

  /**
   * {@inheritdoc}
   */
  public function getPath($file, $module, $profile) {
    if ($profile != '' && strpos($profile, DIRECTORY_SEPARATOR) === FALSE) {
      $profile .= DIRECTORY_SEPARATOR;
    }
    return drupal_get_path('module', $module) . DIRECTORY_SEPARATOR . $profile . $file;
  }

  /**
   * Parses YAML file into a PHP value.
   *
   * @param string $file
   *   The filename.
   * @param string $module
   *   The module where the Yaml file is placed.
   * @param string $profile
   *   The profile used.
   *
   * @return mixed
   *   The YAML converted to a PHP value.
   */
  public function parseFileFromModule($file, $module, $profile) {
    return $this
      ->parse(file_get_contents($this
      ->getPath($file, $module, $profile)));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DemoContentParser::getPath public function Returns the path for the given file. Overrides DemoContentParserInterface::getPath
DemoContentParser::parseFileFromModule public function Parses YAML file into a PHP value. Overrides DemoContentParserInterface::parseFileFromModule