Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
25 - 1
<?php
2
/**
3
 * Copyright 2017 Facebook, Inc.
4
 *
5
 * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
 * use, copy, modify, and distribute this software in source code or binary
7
 * form for use in connection with the web services and APIs provided by
8
 * Facebook.
9
 *
10
 * As with any software that integrates with the Facebook platform, your use
11
 * of this software is subject to the Facebook Developer Principles and
12
 * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
 * shall be included in all copies or substantial portions of the software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 *
23
 */
24
 
25
/**
26
 * You only need this file if you are not using composer.
27
 * Why are you not using composer?
28
 * https://getcomposer.org/
29
 */
30
 
31
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
32
    throw new Exception('The Facebook SDK requires PHP version 5.4 or higher.');
33
}
34
 
35
require_once __DIR__ . '/polyfills.php';
36
 
37
/**
38
 * Register the autoloader for the Facebook SDK classes.
39
 *
40
 * Based off the official PSR-4 autoloader example found here:
41
 * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
42
 *
43
 * @param string $class The fully-qualified class name.
44
 *
45
 * @return void
46
 */
47
spl_autoload_register(function ($class) {
48
    // project-specific namespace prefix
49
    $prefix = 'Facebook\\';
50
 
51
    // For backwards compatibility
52
    $customBaseDir = '';
53
    // @todo v6: Remove support for 'FACEBOOK_SDK_V4_SRC_DIR'
54
    if (defined('FACEBOOK_SDK_V4_SRC_DIR')) {
55
        $customBaseDir = FACEBOOK_SDK_V4_SRC_DIR;
56
    } elseif (defined('FACEBOOK_SDK_SRC_DIR')) {
57
        $customBaseDir = FACEBOOK_SDK_SRC_DIR;
58
    }
59
    // base directory for the namespace prefix
60
    $baseDir = $customBaseDir ?: __DIR__ . '/';
61
 
62
    // does the class use the namespace prefix?
63
    $len = strlen($prefix);
64
    if (strncmp($prefix, $class, $len) !== 0) {
65
        // no, move to the next registered autoloader
66
        return;
67
    }
68
 
69
    // get the relative class name
70
    $relativeClass = substr($class, $len);
71
 
72
    // replace the namespace prefix with the base directory, replace namespace
73
    // separators with directory separators in the relative class name, append
74
    // with .php
75
    $file = rtrim($baseDir, '/') . '/' . str_replace('\\', '/', $relativeClass) . '.php';
76
 
77
    // if the file exists, require it
78
    if (file_exists($file)) {
79
        require $file;
80
    }
81
});