Skip to content

Commit d25ee5a

Browse files
committed
Auto-Formated DefaultController
1 parent 21854c0 commit d25ee5a

File tree

1 file changed

+123
-122
lines changed

1 file changed

+123
-122
lines changed

Symfony/src/Codebender/CompilerBundle/Controller/DefaultController.php

Lines changed: 123 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
\file
4-
\brief Functions used by the compiler backend.
5-
6-
\author Dimitrios Christidis
7-
\author Vasilis Georgitzikis
8-
9-
\copyright (c) 2012-2013, The Codebender Development Team
10-
\copyright Licensed under the Simplified BSD License
3+
* \file
4+
* \brief Functions used by the compiler backend.
5+
*
6+
* \author Dimitrios Christidis
7+
* \author Vasilis Georgitzikis
8+
*
9+
* \copyright (c) 2012-2013, The Codebender Development Team
10+
* \copyright Licensed under the Simplified BSD License
1111
*/
1212

1313
namespace Codebender\CompilerBundle\Controller;
@@ -56,7 +56,7 @@ public function indexAction($auth_key, $version)
5656
{
5757
$request = $this->getRequest()->getContent();
5858

59-
//Get the compiler service
59+
//Get the compiler service
6060
$compiler = $this->get('compiler_handler');
6161

6262
$reply = $compiler->main($request, $params);
@@ -69,126 +69,127 @@ public function indexAction($auth_key, $version)
6969
}
7070
}
7171

72-
public function deleteAllObjectsAction($auth_key, $version)
73-
{
74-
if ($this->container->getParameter('auth_key') != $auth_key)
75-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid authorization key.")));
76-
77-
if ($version != "v1")
78-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid API version.")));
79-
80-
$tempDir = $this->container->getParameter('temp_dir');
81-
$objectFilesDir = $this->container->getParameter('objdir');
82-
$fileCount = 0;
83-
$undeletedFiles = "";
84-
$deletionStats = array("success_dot_a" => 0,
85-
"failure_dot_a" => 0,
86-
"success_dot_o" => 0,
87-
"failure_dot_o" => 0,
88-
"success_dot_d" => 0,
89-
"failure_dot_d" => 0,
90-
"success_dot_LOCK" => 0,
91-
"failure_dot_LOCK" => 0);
92-
93-
if ($handle = opendir("$tempDir/$objectFilesDir"))
94-
{
95-
96-
while (false !== ($entry = readdir($handle)))
97-
{
98-
if ($entry != "." && $entry != ".." && $entry != ".DS_Store")
99-
{
100-
$fileCount++;
101-
$extension = pathinfo($entry, PATHINFO_EXTENSION);
102-
103-
if (!in_array($extension, array("a", "o", "d", "LOCK")))
104-
continue;
105-
106-
if (@unlink("$tempDir/$objectFilesDir/$entry") === false)
107-
{
108-
$deletionStats["failure_dot_$extension"]++;
109-
$undeletedFiles .= $entry . "\n";
110-
}
111-
else
112-
$deletionStats["success_dot_$extension"]++;
113-
}
114-
}
115-
closedir($handle);
116-
}else
117-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Failed to access object files directory.")));
118-
119-
return new Response(json_encode(array_merge(array("success" => true,
120-
"message" => "Object files deletion complete. Found $fileCount files."),
121-
$deletionStats,
122-
array("Files not deleted" => $undeletedFiles))));
123-
}
124-
125-
public function deleteSpecificObjectsAction($auth_key, $version, $option, $to_delete)
126-
{
127-
if ($this->container->getParameter('auth_key') != $auth_key)
128-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid authorization key.")));
129-
130-
if ($version != "v1")
131-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid API version.")));
132-
133-
$tempDir = $this->container->getParameter('temp_dir');
134-
$objectFilesDir = $this->container->getParameter('objdir');
135-
136-
if ($option == "core")
137-
$to_delete = str_replace(":", "_", $to_delete);
138-
139-
$response = array();
140-
$response["deleted_files"] = "";
141-
$response["undeleted_files"] = "";
142-
143-
if ($handle = opendir("$tempDir/$objectFilesDir"))
144-
{
145-
while (false !== ($entry = readdir($handle)))
146-
{
147-
if ($entry == "." || $entry == ".." || $entry == ".DS_Store")
148-
continue;
149-
150-
if ($option == "library" && strpos($entry, "______" . $to_delete . "_______") === false)
151-
continue;
152-
153-
if ($option == "core" && strpos($entry, "_" . $to_delete . "_") === false)
154-
continue;
155-
156-
157-
if (@unlink("$tempDir/$objectFilesDir/$entry") === false)
158-
$response["undeleted_files"] .= $entry . "\n";
159-
else
160-
$response["deleted_files"] .= $entry . "\n";
161-
162-
}
163-
closedir($handle);
164-
}
165-
else
166-
{
167-
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Failed to access object files directory.")));
168-
}
169-
170-
if ($response["undeleted_files"] != "")
171-
{
172-
$message = ($option == "library") ? "Failed to delete one or more of the specified library object files.": "Failed to delete one or more of the specified core object files.";
173-
return new Response(json_encode(array_merge(array("success" => false, "step" => 0, "message" => $message), $response)));
174-
}
175-
176-
$message = ($option == "library") ? "Library deleted successfully.": "Core object files deleted successfully.";
177-
return new Response(json_encode(array_merge(array("success" => true, "message" => $message), $response)));
178-
}
72+
public function deleteAllObjectsAction($auth_key, $version)
73+
{
74+
if ($this->container->getParameter('auth_key') != $auth_key)
75+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid authorization key.")));
17976

180-
/**
181-
\brief Creates a list of the configuration parameters to be used in the compilation process.
77+
if ($version != "v1")
78+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid API version.")));
79+
80+
$tempDir = $this->container->getParameter('temp_dir');
81+
$objectFilesDir = $this->container->getParameter('objdir');
82+
$fileCount = 0;
83+
$undeletedFiles = "";
84+
$deletionStats = array("success_dot_a" => 0,
85+
"failure_dot_a" => 0,
86+
"success_dot_o" => 0,
87+
"failure_dot_o" => 0,
88+
"success_dot_d" => 0,
89+
"failure_dot_d" => 0,
90+
"success_dot_LOCK" => 0,
91+
"failure_dot_LOCK" => 0);
92+
93+
if ($handle = opendir("$tempDir/$objectFilesDir"))
94+
{
95+
96+
while (false !== ($entry = readdir($handle)))
97+
{
98+
if ($entry != "." && $entry != ".." && $entry != ".DS_Store")
99+
{
100+
$fileCount++;
101+
$extension = pathinfo($entry, PATHINFO_EXTENSION);
102+
103+
if (!in_array($extension, array("a", "o", "d", "LOCK")))
104+
continue;
105+
106+
if (@unlink("$tempDir/$objectFilesDir/$entry") === false)
107+
{
108+
$deletionStats["failure_dot_$extension"]++;
109+
$undeletedFiles .= $entry."\n";
110+
}
111+
else
112+
$deletionStats["success_dot_$extension"]++;
113+
}
114+
}
115+
closedir($handle);
116+
}
117+
else
118+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Failed to access object files directory.")));
119+
120+
return new Response(json_encode(array_merge(array("success" => true,
121+
"message" => "Object files deletion complete. Found $fileCount files."),
122+
$deletionStats,
123+
array("Files not deleted" => $undeletedFiles))));
124+
}
125+
126+
public function deleteSpecificObjectsAction($auth_key, $version, $option, $to_delete)
127+
{
128+
if ($this->container->getParameter('auth_key') != $auth_key)
129+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid authorization key.")));
130+
131+
if ($version != "v1")
132+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid API version.")));
133+
134+
$tempDir = $this->container->getParameter('temp_dir');
135+
$objectFilesDir = $this->container->getParameter('objdir');
182136

183-
\return An array of the parameters.
137+
if ($option == "core")
138+
$to_delete = str_replace(":", "_", $to_delete);
184139

185-
This function accesses the Symfony global configuration parameters, and creates an array that our handlers (which
186-
don't have access to them) can use them.
140+
$response = array();
141+
$response["deleted_files"] = "";
142+
$response["undeleted_files"] = "";
143+
144+
if ($handle = opendir("$tempDir/$objectFilesDir"))
145+
{
146+
while (false !== ($entry = readdir($handle)))
147+
{
148+
if ($entry == "." || $entry == ".." || $entry == ".DS_Store")
149+
continue;
150+
151+
if ($option == "library" && strpos($entry, "______".$to_delete."_______") === false)
152+
continue;
153+
154+
if ($option == "core" && strpos($entry, "_".$to_delete."_") === false)
155+
continue;
156+
157+
158+
if (@unlink("$tempDir/$objectFilesDir/$entry") === false)
159+
$response["undeleted_files"] .= $entry."\n";
160+
else
161+
$response["deleted_files"] .= $entry."\n";
162+
163+
}
164+
closedir($handle);
165+
}
166+
else
167+
{
168+
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Failed to access object files directory.")));
169+
}
170+
171+
if ($response["undeleted_files"] != "")
172+
{
173+
$message = ($option == "library") ? "Failed to delete one or more of the specified library object files." : "Failed to delete one or more of the specified core object files.";
174+
return new Response(json_encode(array_merge(array("success" => false, "step" => 0, "message" => $message), $response)));
175+
}
176+
177+
$message = ($option == "library") ? "Library deleted successfully." : "Core object files deleted successfully.";
178+
return new Response(json_encode(array_merge(array("success" => true, "message" => $message), $response)));
179+
}
180+
181+
/**
182+
* \brief Creates a list of the configuration parameters to be used in the compilation process.
183+
*
184+
* \return An array of the parameters.
185+
*
186+
* This function accesses the Symfony global configuration parameters, and creates an array that our handlers (which
187+
* don't have access to them) can use them.
187188
188189
*/
189190
private function generateParameters()
190191
{
191-
$parameters = array("binutils", "python", "clang", "logdir", "temp_dir", "archive_dir", "autocompletion_dir", "autocompleter", "cflags", "cppflags", "asflags", "arflags", "ldflags", "ldflags_tail", "clang_flags", "objcopy_flags", "size_flags", "output", "arduino_cores_dir", "external_core_files", "auth_key");
192+
$parameters = array("binutils", "python", "clang", "logdir", "temp_dir", "archive_dir", "autocompletion_dir", "autocompleter", "cflags", "cppflags", "asflags", "arflags", "ldflags", "ldflags_tail", "clang_flags", "objcopy_flags", "size_flags", "output", "arduino_cores_dir", "external_core_files", "auth_key");
192193

193194
$compiler_config = array();
194195

0 commit comments

Comments
 (0)