Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Camo Image Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
Camo Image Proxy
Commits
ba58ff06
Commit
ba58ff06
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Trait for forthcoming singletons
parent
c5eb7547
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!6
add linting
,
!5
WIP: Add JUnit reporting
,
!4
WIP: Initial release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
camo-image-proxy.php
+8
-1
8 additions, 1 deletion
camo-image-proxy.php
inc/trait-singleton.php
+40
-0
40 additions, 0 deletions
inc/trait-singleton.php
with
48 additions
and
1 deletion
camo-image-proxy.php
+
8
−
1
View file @
ba58ff06
...
@@ -12,4 +12,11 @@
...
@@ -12,4 +12,11 @@
* @package Camo_Image_Proxy
* @package Camo_Image_Proxy
*/
*/
// Your code starts here.
namespace
Camo_Image_Proxy
;
define
(
__NAMESPACE__
.
'\PLUGIN_PATH'
,
dirname
(
__FILE__
)
);
/**
* Trait for singletons
*/
require_once
PLUGIN_PATH
.
'/inc/trait-singleton.php'
;
This diff is collapsed.
Click to expand it.
inc/trait-singleton.php
0 → 100644
+
40
−
0
View file @
ba58ff06
<?php
/**
* Trait file for Singletons.
*
* @package Camo_Image_Proxy
*/
namespace
Camo_Image_Proxy
;
/**
* Make a class into a singleton.
*/
trait
Singleton
{
/**
* Existing instance.
*
* @var object
*/
protected
static
$instance
;
/**
* Get class instance.
*
* @return object
*/
public
static
function
instance
()
{
if
(
!
isset
(
static
::
$instance
)
)
{
static
::
$instance
=
new
static
();
static
::
$instance
->
setup
();
}
return
static
::
$instance
;
}
/**
* Setup the singleton.
*/
public
function
setup
()
{
// Silence.
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment